wordpressの動作環境をapacheからnginxへの切り替え作業中です。
サーバのOSはcentOS7です。
https://gist.github.com/LeCoupa/e29a457841dc4dd60006
https://qiita.com/koni/items/05158e33b4c8aac07b59
まずは上記のサイトを参考に、下記のようなファイルを作成しました。
# etc/nginx/conf.d/wordpress.conf ## # @server studio # @host hackisition.com # @desc nginx host rules # @author Julien Le Coupanec <julien@gentlenode.com> ## # HTTP Server server { listen 80; server_name example.com; rewrite ^ https://$server_name$request_uri permanent; } # HTTPS Server server { listen 443; server_name example.com; root /var/www/html; index index.php; error_log /var/log/nginx/example.com.log crit; ssl on; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # do not use SSLv3 ref: POODLE client_max_body_size 20M; location / { try_files $uri $uri/ /index.php; } location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } location ~/.ht { deny all; } }
参考サイトでは「php5-fpm.sock」だったのですが、当環境はphp7で動作しており、5ではバージョンが合わないと思ったので、インストールの際は「yum install php-fpm」で行いました。
# /etc/php-fpm.d/www.conf user = nginx group = nginx listen = /var/run/php-fpm/php-fpm.sock listen.owner = nginx listen.group = nginx listen.mode = 0660 # 残りの項目は変更なし
上記作成後、apacheを停止し、nginxとphp-fpmを起動してからwordpressを開いてみましたが、タイトルが「502 bad gateway」で、内容が真っ白のエラーページが表示されてしまいました。
「/var/run/php-fpm/php-fpm.sock」ファイルが作成自体はされているのですが、0バイトのファイルになっており、FTPから開くことやダウンロードすることができません。削除はできます。
「php-fpm」フォルダおよび「php-fpm.sock」のユーザとグループは、ともにnginxとなっていました。
また、エラーログには以下のように記載されていました。
# /var/log/nginx/example.com.log 2017/12/08 11:47:00 [crit] 3626#3626: *61 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: wiredpunch.com, request: "GET /....../ HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "wiredpunch.com", referrer: "https://......." # 以下、同様のメッセージが延々と。数値やURLやIPアドレスの部分は変動。
# /var/log/php-fpm/error.log [08-Dec-2017 12:32:43] NOTICE: Terminating ... [08-Dec-2017 12:32:43] NOTICE: exiting, bye-bye! [08-Dec-2017 12:32:43] NOTICE: fpm is running, pid 5584 [08-Dec-2017 12:32:43] NOTICE: ready to handle connections [08-Dec-2017 12:32:43] NOTICE: systemd monitor interval set to 10000ms # 以下同文。
「No such file or directory」が出るということは「php-fpm.sock」が見つからないということだと思われ、やはり0バイトになるのは異常なのでしょうか。
どうすれば正常に「php-fpm.sock」を作成させられるのでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。