Nginx

1.下载对应当前系统版本的nginx包(package)

wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.建立nginx的yum仓库

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

3.下载并安装nginx

yum install nginx -y

4.启动nginx服务

systemctl start nginx.service
systemctl enable nginx.service

5.设置防火墙并开启80端口

systemctl start firewalld.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

6.配置nginx支持php

cp /etc/nginx/conf.d/default.conf /opt/default.conf.back
cd /etc/nginx/conf.d/
vim default.conf

修改文件使其支持php

charset utf-8;

location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

location ~ \.php$ {
        root           html;
        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;
    }

重启nginx服务

systemctl restart nginx.service

查看nginx状态

systemctl status nginx.service

7.测试PHP服务

cd /usr/share/nginx/html/

添加index.php文件

vim index.php

<?php
    phpinfo();
?>

打开浏览器测试

http://ip/index.php

results matching ""

    No results matching ""