LoginSignup
6
6

More than 5 years have passed since last update.

PHP-FPM をインストールして Nginxに設定

Posted at

参考サイト

PHP-FPMのインストールと設定

PHP-FPMをremi経由でインストール

sudo yum --enablerepo=remi install php php-fpm -y

設定ファイルを編集

sudo cp /etc/php-fpm.d/www.conf  /etc/php-fpm.d/www.conf.org

sudo vim /etc/php-fpm.d/www.conf

www.conf

# apache から nginx に変更
user = nginx
group = nginx

サービスを起動して自動起動をON

sudo service php-fpm start

sudo chkconfig php-fpm on

nginx の設定

vim /etc/nginx/conf.d/default.conf

default.conf
server {
    listen       80 default_server;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        root /var/www/vhosts/default/public;
        index  index.html index.htm index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
        location ~ \.php$ {
        root /var/www/vhosts/default/public;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        include fastcgi_params;
        }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

nginx を再起動

sudo service nginx restart

以上

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6