【发布时间】:2018-08-03 16:43:18
【问题描述】:
我在 Windows 上开发了一些 wordpress 网站,它运行良好,没有任何问题。现在我需要迁移到带有 Nginx 和 PHP 7.2 的 Ubuntu 18.04 服务器。
我都是按照手册来做的,但是任何 wordpress 页面都以空白页打开:( 我通过使用 phpinfo() 添加到主文件夹 phpinfo.php 来测试它;代码,它打开没有问题,因为 domain/phpinfo.php,图像和 html 文件也打开没有问题,作为 domain/image.png 或 domain/file.html。
最糟糕的是我没有收到任何错误:(
这是我的域配置:
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ; }
map $blogname $blogid{
default -999;
#Ref: http://wordpress.org/extend/plugins/nginx-helper/
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ; }
server {
server_name domain;
root /srv/domain;
index index.php;
access_log /var/log/nginx/domain.access.log;
error_log /var/log/nginx/domain.error.log;
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /srv/domain/htdocs/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
try_files $uri =404; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
#add some rules for static content expiry-headers here }
这是我的 nginx.conf 文件:
user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;
events { worker_connections 768; }
http {
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
提前致谢
【问题讨论】: