2014-10-16 56 views
0

我對位於/ var/www/html等/ site1的 訪問的CentOS 6.5 WordPress的多站點在site1.com和那裏的一切都很好。如何安裝一個站點內的另一個與Nginx的

我想在site1.com/site2

爲Site1內的.conf在 的/ var/www/html等/ SITE2但 訪問安裝一個名爲SITE2一個單一的網站有這樣的服務器塊:

  location/{ 
         try_files $uri $uri/ /index.php?$args; 
         } 

      #editing here to... 
      location /site2 { 
       root /var/www/html/site2/; 
       index index.php index.html index.htm; 
       try_files /index.html /index.php $uri $uri/; 
      } 

      location ~ /site2/(.*\.php)$ { 
       root /var/www/html/site2/; 
       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_index index.php; 
       fastcgi_param SCRIPT_FILENAME $document_root$1; 
       include /etc/nginx/fastcgi_params; 

       location ~ \.php$ { 
        fastcgi_pass 127.0.0.1:9000; 
        fastcgi_index index.php; 
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
        include  /etc/nginx/fastcgi_params; 
       } 

      } 

      #end editing. 

當我使用try文件時try_files /index.html /index.php $ uri $ uri /;有用。 當我使用try_files try_files的index.php $ URI $ URI /;瀏覽器下載文件而不是顯示它。

回答

0

所在地塊應該做的伎倆,只要你定義位置的新根:

location /site2 
{ 
    root /var/www/html/site2; 

    #put your rewrite rules here 
} 

你必須確保你的FastCGI(我假設找你使用PHP-FPM)配置也使用新的docroot。 我不知道WordPress的非常好,但我想你也有第二個站點配置是在一個名爲/site2子目錄,否則鏈接可能無法正常工作。

+0

將與此打一聲。 Thx的迴應。 – chris 2014-10-16 13:15:43

+0

我靠近但沒有雪茄。即使在site2中有一個空白的index.php,我也會得到一個site1 404。任何想法? – chris 2014-10-16 14:54:32

+0

您能否更新您的問題併發布整個配置文件?另外,請檢查404是否由wordpress或nginx生成。 Nginx的incercepts FastCGI的錯誤,並顯示它的每默認自己的404頁: – Steffen 2014-10-16 17:09:15

相關問題