Symfony2 nginx问题 - 未找到所有页面404

时间:2014-07-21 17:39:50

标签: php .htaccess symfony nginx

当我试图在nginx上运行时,我的symfony2项目出现了问题。

www.domain /工作正常

www.domain / app_dev.php,“加载Web调试工具栏时出错(404:Not Found)。你想打开探查器吗?”

www.domain / app.php / someurl / - 404 not found

是服务器配置问题还是应该以某种方式更改我的.htaccess以使其能够与nginx一起运行?

1 个答案:

答案 0 :(得分:1)

您可以检查我的开发配置(使用PHP-FPM):

server {
    listen 80;
    server_name dev.example.com;

    root /var/www/web;

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log error;

    index app.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /app.php/$1;
    }

    location ~ \.php(/|$) {
        # try_files $uri =404;

        fastcgi_index app.php;
        fastcgi_pass unix:/var/run/php5-fpm.sock;

        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;
        fastcgi_buffer_size   1280k;
        fastcgi_buffers   4 2560k;
        fastcgi_busy_buffers_size   2560k;
    }

    location ~ /\.ht {
        deny all;
    }
}