nginxでワードプレス
Apache環境で作成されたワードプレスのコンテンツをnginx環境に移行させたんですが、メニューがすべて「not found」に。。。
原因としては、パーマリンクが基本以外になっていたためでした。。
※これがわかるまで、再インストールしたりデータベースいじってみたりorz
nginxってhtaccessが使えないんですね。。使えないんです。。。
そのため、htaccessに書いていいた内容をnginx.confに書いてやる必要があります。
nginx.confを編集します。
SSLで設定しているサンプルです。
server {listen 443 ssl http2 ;listen [::]:443 ssl http2 ;server_name exp.com;root /opt/exp/public_html;index index.php index.html index.htm;client_max_body_size 20M;
ssl_certificate /etc/letsencrypt/live/exp.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/exp.com/privkey.pem;
ssl_session_cache shared:SSL:1m;ssl_session_timeout 10m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;
access_log /var/log/nginx/exp.com.ssl.log main;error_log /var/log/nginx/exp.com.error.ssl.log warn;
# URLでトライして、見つからない場合は@wordpressロケーションへ飛ばすlocation / { try_files $uri $uri/ @wordpress;}
error_page 404 /404.html;location = /40x.html {}
error_page 500 502 503 504 /50x.html;location = /50x.html {}
location ~ \.php$ { # 通常の.phpでアクセスしてきて、見つからない場合は@wordpressロケーションへ飛ばす
try_files $uri @wordpress; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}
#ワードプレスのindex.phpへ飛ばすlocation @wordpress { fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_param SCRIPT_FILENAME /opt/exp/public_html/index.php; include fastcgi_params;}}
しらんがな。。。。
い、いや。。。。
思わず。。。
