我在部署Silex項目的服務器上收到此錯誤。FastCGI在stderr中發送:「主要腳本未知」 - nginx和silex
在這個服務器我已經有nginx的傳遞請求從/
加入燒瓶中的應用程序在端口上運行5000
所以,從我的倉庫拉新項目/var/www/newproject
我試圖nginx的配置經過了這麼一個請求http://xxx.xxx.xxx.xxx/newproject
將根目錄爲/var/www/newproject
這是一個silex應用程序。
我搜索了網頁,我找到的所有配置都沒有解決我的問題。 訪問任何路線,返回404
我的整個配置是這樣的:
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
access_log /var/log/myproject/nginx_access.log;
error_log /var/log/myproject/nginx_error.log;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
location /newproject {
root /var/www;
try_files $uri $uri/ =404;
index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/newproject/index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /var/www/newproject$fastcgi_script_name;
include fastcgi_params;
}
location/{
root /opt/myproject;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://xxx.xxx.xxx.xxx:5000;
break;
}
}
}
缺少什麼我在這裏?
謝謝。
UPDATE:
嘗試了新的配置(如下),現在訪問http://xxx.xxx.xxx.xxx/newproject/SOME_PATH我有一個404
open() "/var/www/newproject/SOME_PATH" failed (20: Not a directory)
open() "/var/www/newproject/index.php/SOME_PATH" failed (20: Not a directory)
location /newproject {
root /var/www/;
index index.php index.html index.htm;
location ~ ^/newproject/(.+\.php)$ {
try_files $uri =404;
root /var/www/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS off;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
}
location ~* ^/newproject/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /var/www/;
}
}