我从Nginx开始,并且有很多问题,因为事情从Apache变成了Nginx。 现在我有一个在Symfony1.4开发的应用程序,因为我得到了一个404 Not Found错误,所以不起作用。 这是错误的日志:
2014/02/07 21:28:49 [error] 2091#0: *22 open() "/var/www/html/apps/monitor/web/index.php/login" failed (20: Not a directory), client: 192.168.3.1, server: devserver, request: "POST /apps/monitor/web/index.php/login HTTP/1.1", host: "devserver", referrer: "http://devserver/apps/monitor/web/" 2014/02/07 21:29:11 [error] 2091#0: *22 open() "/var/www/html/apps/monitor/web/login" failed (2: No such file or directory), client: 192.168.3.1, server: devserver, request: "GET /apps/monitor/web/login HTTP/1.1", host: "devserver"
这是我的/etc/nginx/conf.d/default.conf文件的内容:
server { listen 80; server_name devserver; root /var/www/html; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { index index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
哪里不对?
增加了try_files指令
我已经添加了try_files如下,但没有解决我遇到的问题:
try_files $uri $uri/ /index.php?$args;
编辑2:尝试另一种方式,得到500服务器错误
我已经尝试了另一种替代scheme,改为:
index index.php app.php index.html index.htm;
try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php/$1; } location ~ \.php$ { fastcgi_index app.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
但日志说:
2014/02/07 22:06:11 [error] 2905#0: *2 rewrite or internal redirection cycle while internally redirecting to "/apps/monitor/web/index.php/login", client: 192.168.3.1, server: devserver, request: "GET /apps/monitor/web/index.php/login HTTP/1.1", host: "devserver"