LoginSignup
8
8

More than 5 years have passed since last update.

nginx - PHP-FPM 間の通信を UNIX ドメインソケットに変更する

Last updated at Posted at 2015-03-16

PHP-FPM の設定変更

# sed -i -e 's/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm\/php-fpm.sock/' /etc/php-fpm.d/www.conf
# sed -i -e 's/;listen.owner = nobody/listen.owner = nginx/' /etc/php-fpm.d/www.conf
# sed -i -e 's/;listen.group = nobody/listen.group = nginx/' /etc/php-fpm.d/www.conf

nginx の設定変更

PHP-FPM + nginx インストール(CentOS 6)で作成したバーチャルホストに対して設定する。

# sed -i -e 's/fastcgi_pass   127.0.0.1:9000;/fastcgi_pass   unix:\/var\/run\/php-fpm\/php-fpm.sock;/' /etc/nginx/sites-available/virtualhost.conf

PHP-FPM と nginx の再起動

# /etc/rc.d/init.d/php-fpm restart
# /etc/rc.d/init.d/nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# /etc/rc.d/init.d/nginx restart
# ls -l /var/run/php-fpm/php-fpm.sock 
srw-rw----. 1 nginx nginx 0  3月 16 08:15 2015 /var/run/php-fpm/php-fpm.sock

動作確認

# echo '<?php phpinfo();' > /usr/share/nginx/virtualhost/index.php

ブラウザで以下のURLにアクセスして、PHP情報が表示されることを確認する。
http://virtualhost.tatsunet.net/

8
8
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
8
8