nginxでPHPを動かす
httpではPHPが動くのにhttpsで動かない状態を改善する方法をメモとして残します。
nginx/conf.d/default.conf設定に以下を追加します。
rootフォルダは任意に変更してください。
default.conf
server {
listen 443 ssl http2;
server_name sample.com;
if ($request_uri ~ ^.*/index.html$){
rewrite ^(.*)/index.html$ $1/ permanent;
}
location / {
root /html;
index index.html index.htm index.php;
}
ssl_protocols TLSv1.2;
ssl_ciphers EECDH+AESGCM:EECDH+AES;
ssl_ecdh_curve prime256v1;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /html;
}
location ~ \.php$ {
root /html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
以上