2013-12-08 46 views
0

我是NGINX configs的新手,所以請耐心等待。下面是我的配置,其對整個網站正常工作:Nginx的WordPress配置,在主題目錄中的PHP文件不傳遞給FastCGI

server { 
listen ...; 
server_name funkyoslo.no; 

#charset koi8-r; 
#access_log /var/log/nginx/log/host.access.log main; 

location/{ 
    root /usr/share/nginx/funkyoslo.webbr.org/html; 
    index index.php index.html index.htm; 
    try_files $uri $uri/ /index.php?q=$uri&$args; 
} 
error_page 500 502 503 504 /50x.html; 
location = /50x.html { 
    root /usr/share/nginx/funkyoslo.webbr.org/html/; 
} 
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
location ~ \.php$ { 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/funkyoslo.webbr.org/html/$fastcgi_script_name; 
    include  fastcgi_params; 
} 
} 

不過,我試圖加載文件/wp-content/themes/funkyoslo/load-songs.php和它給了我一個500內部服務器錯誤。我檢查了錯誤日誌,顯然該文件根本不傳遞給FastCGI。

我嘗試添加以下塊無濟於事:

location ~ .*/wp-content/themes/funkyoslo/.*\.php$ { 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/funkyoslo.webbr.org/html/wp-content/themes/funkyoslo/$fastcgi_script_name; 
    include   fastcgi_params; 
} 

任何幫助,不勝感激!

回答

0

看我不知道你的配置有什麼問題,但試試這個,並希望它應該工作,這是最小的配置。

注意

  • 刪除索引服務器的塊級,檢查link知道爲什麼
  • 刪除根服務器的塊級,檢查link知道爲什麼
  • 刪除所有額外配置從PHP的塊級別,通過試驗,我意識到我只需要我寫的那兩個。
  • 添加了http://fastcgi_pass,我不知道這是否真的需要,但我習慣於這樣寫。

編輯:好吧顯然我不需要http://,我只是檢查。

-

server { 
    listen 80; 
    server_name funkyoslo.no; 
    root /usr/share/nginx/funkyoslo.webbr.org/html; 
    error_page 500 502 503 504 /50x.html; 
    index index.php index.html index.htm; 
    location/{ 
     try_files $uri $uri/ /index.php$request_uri; 
    } 
    location ~ \.php$ { 
     include fastcgi_params; 
     fastcgi_pass http://127.0.0.1:9000; 
    } 
} 
+0

這使我以下錯誤: [EMERG] 8088#0:* 1:在上游「http://127.0.0.1:$ [錯誤] 8109#0無效的主機重寫或內部重定向循環wh $ –

+0

添加:'fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;'似乎有助於根目錄,但/wp-content/themes/funkyoslo/load-songs.php仍然存在問題 –

+0

Nevermind,它現在可以工作了!顯然,我的PHP文件(由於我的電腦和VPS上的php.ini不同)在PHP-FPM錯誤日誌中顯示錯誤,我無法發現它,因爲AJAX負載是得到安寧給我一個500內部服務器錯誤。 我不認爲我的初始配置有什麼問題,儘管您現在已經爲我提供了一個更好的設置,謝謝! :) –

相關問題