Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
88
Help us understand the problem. What is going on with this article?
@kawakami-kazuyoshi

nginx + php-fpm socketで接続する

More than 5 years have passed since last update.

nginxとphp-fpmとの接続に、UNIX socketを指定する

socket通信を使うとTCPで接続するので、「http://127.0.0.1:9000」でアクセスするより早いのかな?

php-fpm
 ・www.conf(/etc/php-fpm-5.5.d/www.conf)の「listen」を下記に変更する

php-fpm
listen = /var/run/php-fpm/php-fpm.sock

 ・再起動する
  /etc/rc.d/init.d/php-fpm restart

 ・再起動すると、「/var/run/php-fpm」に「php-fpm.sock」が作られる

nginx
 ・confの「fastcgi_path」にphp-fpm.sockを指定する

nginx
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

 ・再起動する
  /etc/rc.d/init.d/nginx restart

アクセス後したら「502 Bad Gateway」になる場合

 ・/var/run/php-fpm/php-fpm.sockのOwner情報を確認する
  ・カッコカリ、確認したところ「root」だったことにします。
 ・php-fpm:www.confの「listen.ownerとlisten.group」を下記に変更する

php-fpm
listen.owner = nginx
listen.group = nginx

 ・再起動する
  /etc/rc.d/init.d/php-fpm restart

88
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
88
Help us understand the problem. What is going on with this article?