nginxの設定メモ
パーマリンクをポスト名に変更しようとするとnginxでエラーになるので修正
/etc/nginx/sites-available/default
# http:// へのアクセスはすべて https:// へリダイレクトする
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.space-balloon.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.space-balloon.org/privkey.pem;
root /var/www/html/www.xxx.org/wordpress;
index index.php;
server_name www.xxx.org;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ @wordpress;
}
# pass PHP scripts to FastCGI server
#location ~ \.php$ {
# try_files $uri =404;
# fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
# modify for wordpress
location ~ \.php$ {
try_files $uri @wordpress;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
#fastcgi_param SCRIPT_FILENAME /usr/share/nginx/wordpress$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @wordpress {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/html/www.xxx.org/wordpress/index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /usr/share/nginx/wordpress/index.php;
include fastcgi_params;
}
access_log /var/log/nginx/wordpress.access.log ;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
}