您的位置:首页 > 运维架构 > Linux

centos6.5里用yum简单安装配置lamp

2014-11-26 14:58 423 查看
源码安装最后老是有点报错,还是yum简单,,,。。。。。

1 首先查看下系统是否已经安装了apache
[root@cc /]# rpm -qa | grep httpd
httpd-tools-2.2.15-29.el6.centos.x86_64
httpd-2.2.15-29.el6.centos.x86_64
删除系统自带的。
[root@cc /]# rpm -e --nodeps httpd-tools-2.2.15-29.el6.centos.x86_64
[root@cc /]# rpm -e --nodeps httpd-2.2.15-29.el6.centos.x86_64

2 开始安装apache
[root@cc /]# yum install httpd -y
安装完成以后用 /etc/init.d/httpd start 启动服务
最后设置开机自动启动apache
[root@cc /]# chkconfig --levels 2345 httpd on

3 测试一下


此时的apache只提供HTTP服务,不能执行php,也不能连接MYSQL数据库
4 安装mysql

yum install mysql mysql-server mysql-devel -y

启动服务 /etc/init.d/mysqld start
5 设置mysql密码
mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
********
mysql> UPDATE user SET Password=PASSWORD('12345678') WHERE user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
**********
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

6 设置开机自动启动
[root@cc /]# chkconfig --levels 2345 mysqld on

7 安装php
[root@cc /]# yum install php -y
安装完成以后重新启动apache
/etc/init.d/httpd restart
这时,Apache已经可以解析执行php脚本了。由于Apache的默认网站根目录位于:/var/www/html/,因此在此目录建立一个info.php用来测试Apache+PHP的正确安装与否:
vim /var/www/html/info.php
里面编辑的内容如下

<html> <title>Apache+php test !</title> <body> <?php phpinfo(); ?> </body> </html> <?php phpinfo();?>

9 然后测试 http://192.168.0.150/info.php



出现上图说明PHP和Apache已经正确安装
8 接下来安装MySQL数据库与其它模块(如GD图形库、mbstring库等):

yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc

安装完以后重新启动Apache
/etc/init.d/httpd restart

重新在浏览器中打开IP/info.php页面,应该能找到MySQL、GD、mbstring等模块

本文出自 “linux运维初学” 博客,请务必保留此出处http://ht712.blog.51cto.com/9397612/1582781
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: