首先检查我的CentOS6是否预装apache [root@foam /]# rpm -qa | grep httpd httpd-tools-2.2.15-29.el6.centos.x86_64 httpd-2.2.15-29.el6.centos.x86_64 果然是安装了的,那么先卸载它。 [root@foam /]# rpm -e httpd warning: /etc/httpd/conf/httpd.conf saved as /etc/httpd/conf/httpd.conf.rpmsave 出来个警告,但是不影响卸载。一、安装Apache1. yum install httpd 2. [root@foam init.d]# /etc/init.d/httpd start Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 23.245.26.38 for ServerName [ OK ] 没找到domain name,使用ip地址做为server name。 设置Domain [root@foam init.d]# cd /etc/httpd/conf [root@foam conf]# vim httpd.conf 找到ServerName。将前面的#去掉 ServerName zoufeng.com:80 :wq 保存 [root@foam conf]# chkconfig httpd on #设为开机启动 [root@foam conf]# /etc/init.d/httpd restart #重启Apache Stopping httpd: [ OK ] Starting httpd: [ OK ] ps:安装并启动apache后,浏览器输入IP,可以访问了。二、安装Mysql1.安装 [root@foam conf]# yum install mysql mysql-server btw:下载速率有8.0M/s [root@foam ~]# /etc/init.d/mysqld start #启动 Initializing MySQL database: Installing MySQL system tables… OK Filling help tables… OK [root@foam ~]# chkconfig mysqld on #设置为开机启动 [root@foam ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf’? #可以覆盖它 2.设置密码 [root@foam /]# mysql_secure_installation 提示需要输入密码 Enter current password for root (enter for none): (默认是空,直接enter即可) Set root password? [Y/n] 接下来输入两次新密码即可 提示是否把匿名用户删除 Remove anonymous users? [Y/n] y … Success! 提示是否不允许root远程登录(安全起见,不允许) Disallow root login remotely? [Y/n] y … Success! 后面还有两个询问,默认Y就可以。 重启Mysql [root@foam ~]# /etc/init.d/mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ]三、安装PHP51.安装 [root@foam ~]# yum install php btw:这次是8.4MB/s 2.安装php组件 [root@foam ~]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt 3.重启mysql和apache [root@foam ~]# /etc/init.d/mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ] [root@foam ~]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] 最后在/var/www/html/下新建index.php。 echo phpinfo(); 浏览器输入ip地址,看到了熟悉的php参数页面。配置成功!! ==============至此LAMP搭建完成================== 如果希望调试PHP,希望显示错误信息,需要到 /etc/php.ini 修改