2012-04-15 73 views
0

我有一堆與nginx + php-fastcgi一起工作的網站,我沒有抱怨!唯一不起作用的是名爲Gallery3的PHP圖庫應用程序。可悲的是,我必須在這個應用程序中使用Apache。我的問題是:Apache + Nginx反向代理默認不服務index.php

gallery.wfto.cc - 不工作(下載包含的index.php的PHP代碼,因爲它是沒有得到解析了一個不知名的文件)

畫廊。 wfto.cc/ - 不工作(同樣的事情)

gallery.wfto.cc/index.php - 不工作(同樣的事情)

gallery.wfto.cc/index.php/- 工作。

gallery.wfto.cc:9001(all variants) - Works。

我不知道發生了什麼事。我在下面列出了大部分配置。 /etc/nginx/conf.d/proxy.conf是一個普通的代理配置,沒什麼特別的。

##NGINX CONFIG## 
server { 
    listen 80; ## listen for ipv4 
    listen [::]:80 default ipv6only=on; ## listen for ipv6 

    root /var/www/vhosts/wfto.cc/subdomains/gallery; 

    server_name gallery.wfto.cc; 
    access_log /var/log/nginx/gallery.wfto.cc.access.log; 

    location/{ 
     proxy_pass http://127.0.0.1:9001; 
     include /etc/nginx/conf.d/proxy.conf; 
    } 
} 
## APACHE CONFIG ## 
<VirtualHost *:9001> 
     ServerAdmin [email protected] 

     DocumentRoot /var/www/vhosts/wfto.cc/subdomains/gallery 
     <IfModule mod_fastcgi.c> 
       AddHandler php5-fcgi .php 
       Action php5-fcgi /php5-fcgi 
       Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi 
       FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization 
     </IfModule> 
     <Directory /> 
       Options FollowSymLinks 
       AllowOverride None 
     </Directory> 
     <Directory /var/www/vhosts/wfto.cc/subdomains/gallery/> 
       Options Indexes FollowSymLinks MultiViews 
       AllowOverride None 
       Order allow,deny 
       allow from all 
     </Directory> 

     ErrorLog ${APACHE_LOG_DIR}/error.log 

     # Possible values include: debug, info, notice, warn, error, crit, 
     # alert, emerg. 
     LogLevel warn 

     CustomLog ${APACHE_LOG_DIR}/access.log combined 

</VirtualHost> 
+0

您確定nginx服務器條目是實際使用的,而不是偶然的(例如URL中的域名錯誤拼寫)?檢查訪問日誌以確保。一些更笨的事情要檢查:重新啓動nginx確保停止後沒有正在運行的進程是活着的;將'root'改爲空目錄(如果它將一切代理到Apache,則nginx不需要訪問該內容)。 – 2012-04-16 16:39:41

+0

我改變了根指向一個空目錄(空目錄),但不會改變任何東西。該服務器塊是唯一一個捕獲該子域上的流量的服務器塊。 – meinemitternacht 2012-04-16 16:58:39

+0

更改爲空目錄之後,您是否檢查過Apache的訪問日誌,無論您的測試實際上是否完全通過Apache?如果你仍然得到「相同的結果」(我假設下載index.php的內容),那麼這也意味着你的瀏覽器只是返回一個緩存結果。 – 2012-04-16 17:50:20

回答

0

我不知道在什麼時候,事情開始工作,但如果你改變服務器的配置請務必清除瀏覽器的緩存徹底。

0

在Apache中的conf補充一點:

<IfModule dir_module> 
    DirectoryIndex index.php 
</IfModule> 
+0

仍然無法使用。我不認爲它與DirectoryIndex有關,因爲當我通過gallery.wfto.cc:9001直接訪問Apache時,它工作正常。 – meinemitternacht 2012-04-15 20:30:21

+0

添加到「位置/」在nginx下面的行: index index.php; – shark555 2012-04-15 20:45:53

+0

也不起作用。 – meinemitternacht 2012-04-15 22:13:51