2017-08-07 86 views
1

我正在嘗試在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; 
} 

任何協助解決這一問題,我們將不勝感激。

+0

即使有多站點,你是不是每個人都需要一個不同的虛擬主機? – Difster

+0

@Difster這是我的瞭解每個站點的單獨主機文件對於通配符DNS條目是不必要的,並且在「server_name」指令中包含通配符。 至於數字海洋文章,這是偉大的,但沒有幫助我解決問題在手邊安裝WP在一個子目錄。通過此設置,在NGINX服務器上,訪問網絡管理區域的重寫不起作用。 –

回答

相關問題