2017-08-07 13 views
1

NGINXサーバにWordPress Multisiteをインストールしようとしています。マルチサイトはサブドメインインストールであり、WordPressはそれ自身のディレクトリにインストールされます。ほとんどのものが機能します(フロントエンドページ、カテゴリ、投稿、管理機能など​​)、マルチサイトネットワーク管理者(/wp-admin/network)に移動しようとすると404エラーが発生します。これは、サブディレクトリをURL(/wp/wp-admin/network)に手動で追加すると機能しますが、自動的にはリダイレクトされません。私はNGINXのconfファイルでさまざまな設定を試みましたが、成功はありませんでした。以下は、今のところ私がconfファイルのために着いたものです。 https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/サブディレクトリにWordPress MultisiteをインストールしてNGINXを設定する

私もconfファイルでIFSを使用することは良いアイデアではありませんので、私はだとnginxのサイトで読む:私は成功せず、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; 
    } 
} 

次のブロックが非常に正当なものであることを確かめないでください。

if (!-e $request_filename) { 
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;   
    rewrite ^/wp(/[^/]+)?(/wp-.*) /wp$2 last;  
    rewrite ^/wp(/[^/]+)?(/.*\.php)$ /wp$2 last; 
} 

これを解決するための支援があれば幸いです。

+0

mutliサイトでも、それぞれに異なる仮想ホストが必要なのですか? – Difster

+0

@Difsterそれは私ですワイルドカードDNSエントリでは、サイトごとに別々のホストファイルが必要ではなく、 'server_name'指示文にワイルドカードを含めることを理解してください。 デジタルオーシャンの記事は素晴らしいですが、WPをサブディレクトリにインストールすることで問題を解決するのに役立ちません。この設定では、NGINXサーバ上で、ネットワーク管理領域にアクセスするための書き換えが機能しません。 –

答えて

関連する問題