日前小編將網站引擎變更使用Nginx後,發生網頁顯示空白現象,依下圖設定後即可解決
編輯網站組態檔
server {
listen 80;
server_name 網站名;
return 301 https://網站名/$request_uri;
}
server {
listen 443;
server_name 網站名;
root 網站位置(完整路徑);
index index.php index.html index.htm;
ssl on;
ssl_certificate 憑證檔案置放完整路徑位置/certificate.crt;
ssl_certificate_key 憑證檔案置放完整路徑位置/private.key;
charset utf-8;
access_log /var/log/nginx/access_wp.log main;
#location / {
# try_files $uri $uri/ =404;
#}
location / {
try_files $uri/ $uri/ /index.php?$args;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
#fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/wordpress$fastcgi_script_name;
include fastcgi_params;
}
}