系统环境:       CentOS release 6.5_2.6.32-431.el6.x86_64
关闭防火墙:    service iptables stop
禁止开机启动:chkconfig iptables off
关闭selinux:   sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
本机ip地址:    192.168.199.xxx


由于centos 默认源没有nginx包,先替换为国内阿里云的源也比较快,再添加epel源(安装nginx 需要)!
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.BAK
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

开始安装
yum -y install gcc
yum -y install nginx*
yum -y install mysql*
yum -y install php-fpm*

启动
service nginx start
service php-fpm start
service mysqld start

修改nginx 支持php
vim /etc/nginx/conf.d/default.conf   #红色部分为添加部分

#
# The default server
#

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
index index.html index.php;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

}
重新加载配置文件
service nginx reload

添加测试文件
vim /usr/share/nginx/html/index.php

phpinfo ();
?>

访问测试是否ok
测试nginx访问:
centos6.5使用yum安装nginx+mysql+php_第1张图片

测试是否支持php
centos6.5使用yum安装nginx+mysql+php_第2张图片

mysql设置root密码
mysqladmin -uroot password "root"

 

加入开机自启动
chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on