LoginSignup
29
26

More than 5 years have passed since last update.

Nginx で「502 Bad Gateway」とか、なんだかエラーログがでるよって時

Last updated at Posted at 2016-04-02

皆大好きNginx

たまーに起動してやろうかと思ったら、
画面には見事に
「502 Bad Gateway」
...はまった Orz

ログを見ると、こんな感じで、Permissionエラー

$ tail -f /var/log/nginx/error.log

*1 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "xxx.xxx.xxx.xxx"

一応確認したら、rootユーザで起動されてました。。。(ログは嘘つかないw

$ ls -l /var/run/php-fpm/php-fpm.sock
srw-rw---- 1 root root 0 /var/run/php-fpm/php-fpm.sock

どうやら、php-fpmのlisten.ownerと、listen.groupを、
nginxユーザに合わせると良いらしいです。

$ vi /etc/php-fpm.d/www.conf

listen.owner = nginx
listen.group = nginx

nginx + php-fpm のユーザを合わせる。
基本ですね。

失礼しました。。。TT

29
26
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
29
26