无法在windows上使用nginx加载sf2中的路由


Unable to load routes in sf2 using nginx on windows

我正在尝试在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;
    }

}

这里怎么了?

此解决方案适用于我的

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;
    } 

我希望这将帮助你