Linux

Nginx:Wordpress:空白頁

  • October 28, 2018

當我嘗試訪問我的網路伺服器時,我得到一個空白頁面。它設置為與 wordpress 一起使用,但事實並非如此。

這是我的 wordpress.conf(位於 conf.d 中):

server {
 listen 80;
 #listen 443 default ssl;

 server_name snapecraft.ddns.net;
 root /var/www/html;

 #ssl_certificate /etc/nginx/ssl/mydomain.crt;
 #ssl_certificate_key /etc/nginx/ssl/mydomain.key;

 access_log /var/log/nginx/access.log;
 error_log /var/log/nginx/error.log error;

 index index.php index.phtml index.html;

 error_page   500 502 503 504 404  /50x.html;

 location = /50x.html {
       root   /usr/share/nginx/html;
 }


 location ~ \.php$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_intercept_errors on;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include /etc/nginx/fastcgi_params;

 }
}

當我這樣做時curl -I snapecraft.ddns.net,結果是:

HTTP/1.1 301 Moved Permanently
Server: nginx/1.15.5
Date: Fri, 26 Oct 2018 16:41:11 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Location: https://snapecraft.ddns.net/

這是我的 nginx.conf:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
   worker_connections  1024;
}


http {
   include       /etc/nginx/mime.types;
   default_type  application/octet-stream;

   log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';

   access_log  /var/log/nginx/access.log  main;

   sendfile        on;
   #tcp_nopush     on;

   keepalive_timeout  65;

   #gzip  on;

   include /etc/nginx/conf.d/*.conf;
}

這是 php.ini 文件: https ://pastebin.com/P6UccG70

當然我重新載入了nginx和PHP

非常感謝您的幫助!

WordPress 可以設置為強制使用 https,但您已在wordpress.conf. 您的伺服器沒有在 HTTPS 上響應,而是重定向到它。

你有兩個選擇:

  1. 使http://snapecraft.ddns.net/(不帶 TLS)成為您網站的規範地址。
  2. 設置啟用 TLS https://snapecraft.ddns.net/

在這個時代,您應該選擇選項 2。

引用自:https://serverfault.com/questions/937412