系统环境: 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.repohttp://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;
}
添加测试文件
vim /usr/share/Nginx/html/index.PHP
<?PHP
PHPinfo ();
?>
访问测试是否ok
测试Nginx访问:
MysqL设置root密码
MysqLadmin -uroot password "root"
加入开机自启动chkconfig Nginx onchkconfig MysqLd onchkconfig PHP-fpm on
原文链接:https://www.f2er.com/centos/377340.html