LoginSignup
2
1

More than 5 years have passed since last update.

WordPress (AMIMOTO) で 502 Bad Gateway が表示されたので、調べてみたら php-fpm.sock failed (2: No such file or directory) とのエラーメッセージが…

Posted at

0.はじめに

AWS EC2 AMIMOTO で WordPress サイトを構築していたんですが、

CloudFront やら ALB を適用し、

ALB - EC2 間を HTTPS(443) から HTTP(80) で通信する様に変更しようとしたところ、

「502 Bad Gateway」 が表示されました。

1.Nginx のアクセスログを確認する。

  1. Nginx のアクセスログを確認したところ、以下の様なエラーメッセージが見つかりました。
    • 2019/04/25 19:23:05 [crit] 2617#2617: *75 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: ***.***.***.***, server: _, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "***.***.***.***"

2.php-fpm について色々と確認すると…。

  1. php-fpm について色々と確認してみたところ、そもそもサービスが動いていないことが判明。
    • $ chkconfig
    • $ php70-php-fpm 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2. php-fpm を自動起動する様に chkconfig on を実行。
    • $ chkconfig php70-php-fpm on
    • $ chkconfig
    • $ php70-php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off

3.php-fpm の www.conf を変更する。

  1. 以下の手順に従って、php-fpm の www.conf を変更します。php70-php-fpm では、/etc/opt/remi/php70/php-fpm.d 配下にありました。
    • $ cd /etc/opt/remi/php70/php-fpm.d/
    • $ sudo cp -fp www.conf www.conf.ORG
    • $ ls -la
    • $ sudo vi www.conf
      • 
        38c38
        < listen = 127.0.0.1:9000
        ---
        > listen = /var/run/php-fpm.sock
        48,50c48,50
        < ;listen.owner = nobody
        < ;listen.group = nobody
        < ;listen.mode = 0660
        ---
        > listen.owner = nginx
        > listen.group = nginx
        > listen.mode = 0660
        
  2. 設定変更後、サーバーを再起動します。

99.ハマりポイント

  • そこまでハマった訳ではないですが…。

  • 最初、www.conf を変更しても何も変わらず…、ちょっとうんうん唸っていたら、php-fpm が起動していないことに気づきました。
  • 盲点でした…。

XX.まとめ

とりあえず、ご参考になれば♪

2
1
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
2
1