我正在尝试在NGINX服务器上安装WordPress多站点。多站点是一个子域安装,WordPress安装在它自己的目录中。大多数情况下都能正常工作(前端页面,类别,帖子,管理功能等),但是当试图导航到多站点网络管理员(/wp-admin/network
)时,我收到了404错误。如果我手动将我的子目录添加到url(/wp/wp-admin/network
),但它不会自动重定向,这可以正常工作。我在我的NGINX conf文件中尝试了很多不同的配置,但都没有成功。以下是我现在为conf文件着陆的内容。使用安装在子目录中的WordPress Multisite配置NGINX
upstream php {
server unix:/var/run/php/php7.0-fpm.sock;
server 127.0.0.1:9000;
}
map $http_host $blogid {
default -999;
#Ref: http://wordpress.org/extend/plugins/nginx-helper/
include /var/www/vhosts/test.example.com/public/wp-content/uploads/nginx-helper/map.conf ;
}
# Default server configuration
#
server {
listen 80;
listen [::]:80;
server_name test.example.com *.test.example.com;
server_name_in_redirect off;
root /var/www/vhosts/test.example.com/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/wp(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^/wp(/[^/]+)?(/.*\.php)$ /wp$2 last;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /wp-admin {
rewrite ^/wp-admin$ /wp/wp-admin/ redirect;
}
location/{
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /wp/index.php?$args;
}
location /wp {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri /wp/index.php;
#fastcgi_split_path_info ^(/wp)(/.*)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
#WPMU Files
location ~ ^/files/(.*)$ {
try_files /wp/wp-content/blogs.dir/$blogid/$uri /wp/wp-includes/ms-files.php?file=$1 ;
access_log off; log_not_found off; expires max;
}
#WPMU x-sendfile to avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/test.example.com/public/wp-content/blogs.dir;
access_log off; log_not_found off; expires max;
}
location ~* ^.+.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
我一直奉行的NGINX现场安装说明没有成功:https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
我也读了NGINX网站,在conf文件中使用IFS是不是一个好主意,所以我不知道下面的块是非常犹太人。
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/wp(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^/wp(/[^/]+)?(/.*\.php)$ /wp$2 last;
}
任何协助解决这一问题,我们将不胜感激。
即使有多站点,你是不是每个人都需要一个不同的虚拟主机? – Difster
@Difster这是我的了解每个站点的单独主机文件对于通配符DNS条目是不必要的,并且在“server_name”指令中包含通配符。 至于数字海洋文章,这是伟大的,但没有帮助我解决问题在手边安装WP在一个子目录。通过此设置,在NGINX服务器上,访问网络管理区域的重写不起作用。 –