nginx的服务器配置文件

时间:2013-09-29 13:29:36

标签: symfony ubuntu nginx php

我正在尝试在ubuntu上的php5-fpm + nginx服务器上安装Symfony。

当我进入/web/app_dev.php时,它显示错误:

  

加载Web调试工具栏时发生错误(404:不是   实测值)。

     

您要打开探查器吗?

当我进入探查器(/web/app_dev.php/_profiler/0db7ac)时,它会告诉:

  

未指定输入文件。

我知道我的服务器配置文件存在问题。这是:

 server {

            listen   80;

           # listen   [::]:80 ipv6only=on;

            root /home/marker/Projects/stereoshoots/www;

            access_log  /home/marker/Projects/stereoshoots/logs/access.log;

            server_name stereoshoots.local;

            index index.php index.html index.htm;





            location / {

                    autoindex  on;

    #                try_files $uri $uri/ @rewrite;

                    try_files $uri $uri/ /index.php;

            }

    #        location @rewrite {

    #                rewrite ^/(.*)$ /index.php?q=$1;

    #        }

            location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml|txt)$ {

                access_log        off;

                expires           30d;

            }

            location = /favicon.ico {

                    return 204;

                    access_log     off;

                    log_not_found  off;

            }

            location ~ \.php$ {

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

                    fastcgi_index index.php;

                    include fastcgi_params;

            }

            location ~ /\.ht {

                    deny all;

            }



    }

我应该编辑什么,才能正确安装symfony?

谢谢!

2 个答案:

答案 0 :(得分:0)

我认为唯一剩下的就是将uri传递给index.php

try_files $uri $uri/ /index.php$request_uri

答案 1 :(得分:0)

你真的有index.php吗?

试试这个:

index app_dev.php;

try_files $uri $uri/ @rewrite;

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

location ~ \.php {

    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_param SERVER_PORT 80;
    fastcgi_param SERVER_NAME stereoshoots.local;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index app_dev.php; 
}

请注意,我已将location ~ \.php$更改为location ~ \.php