我正在尝试在Windows上使用nginx服务器设置symfony 2项目。 http://localhost/app_dev.php
显示symfony安装页面,但在url显示404错误后输入任何内容。即使在该链接的末尾添加斜杠也会引发404错误。所以路由不起作用,甚至不是内置的演示。
配置:
server {
listen 127.0.0.1:80 default_server;
#listen [::1]:80 ipv6only=on;
server_name localhost;
root "c:/wt-nmp/www/admin/web";
autoindex on;
allow 127.0.0.1;
#allow ::1;
deny all;
location / {
index app_dev.php;
try_files $uri /app.php$is_args$args;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
#tools are now served from wt-nmp/include/tools/
location ~ ^/(app|app_dev|config)\.php(/|$) {
try_files $uri =404;
fastcgi_pass php_farm;
include nginx.fastcgi.conf;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php_farm;
include nginx.fastcgi.conf;
}
}
这里有什么问题?
答案 0 :(得分:0)
此解决方案与我合作
location ~ ^/(app|app_dev|config)\.php(/|$) {
try_files $uri =404;
include nginx.fastcgi.conf;
fastcgi_pass php_farm;
}
location ~ \.php$ {
try_files $uri =404;
include nginx.fastcgi.conf;
fastcgi_pass php_farm;
}
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app_dev.php$is_args$args;
}
当你在这里使用app_dev.dev处于开发模式时
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app_dev.php$is_args$args;
}
我希望这会对你有所帮助