安装环境

更新

yum

yum update

apache

安装

yum install httpd -y

启动

service httpd start //start启动,stop停止,restart重启

设为开机自启

chkconfig httpd on

mysql

安装

yum install mysql mysql-server

启动

service mysqld start //start启动,stop停止,restart重启

设为开机自启

chkconfig mysqld on 

根据版本换yum

Centos 5.x

rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

Centos 6.x

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

Centos 7.x

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

根据版本安装php

php5.5

yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64

php5.6

yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

php7

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64

根据版本安装php FRM

php5.5

yum install php55w-fpm

php5.6

yum install php56w-fpm

php7

yum install php70w-fpm

配置环境

apache

1.打开httpd.conf

vim /etc/httpd/conf/httpd.conf

2.添加php扩展

搜索

AddType application/x-gzip .gz .tgz

在后面添加

AddType application/x-httpd-php .php

3.添加默认php后缀

搜索

DirectoryIndex index.html

并添加为如下

DirectoryIndex index.html index.htm index.php

4.开启.htaccess重写规则

搜索

Options FollowSymLinks
AllowOverride None

更改为

Options FollowSymLinks
AllowOverride All

5.移除rewrite_model前面的注释

 LoadModule rewrite_module modules/mod_rewrite.so

6.开启php错误提示(开发提示使用,可自行决定是否开启)

添加

php_flag display_errors on
php_value error_reporting 2039

php

1.打开php.ini

vim  /etc/php.ini

2.更改时区

date.timezone = PRC

3.开启错误日志纪录

log_errors = On

4.设置最大上传文件大小

upload_max_filesize = 40M 

5.开启错误提示

搜索并修改如下

display_errors = On
error_reporting = E_ALL | E_STRICT

总结

到目前为止,centos6.5下的LAMP安装与配置基本完成了,服务器的网站地址位于 /var/www/html 下。join in!