Nginx + PHP on CentOS 7

# sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# sudo yum -y update nginx-release-centos
# sudo yum -y --enablerepo=nginx install nginx
# nginx -v
# sudo vim /etc/nginx/conf.d/default.conf
:   
    # ポートを80はhttpdが利用しているので81に変更
    listen       81;
    :
    # 以下セクションをコメントイン
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
:
# lsof -i:81
# sudo cp -p /usr/lib/firewalld/services/http.xml /etc/firewalld/services/http-81.xml
# sudo vim /etc/firewalld/services/http-81.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
  :
  <port protocol="tcp" port="81"/>
</service
# sudo firewall-cmd --add-service=http-81 --zone=public --permanent
# sudo firewall-cmd --reload
# sudo yum -y install php-fpm
# sudo systemctl php-fpm
# sudo vim /usr/share/nginx/html/phpinfo.php
<?php
phpinfo();
?>
# sudo systemctl nginx

http://localhost:81/phpinfo.php

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*