安装好后,直接访问http://localhost/Symfony/web/app_dev…. 会出现welcome页面,但是会弹出一个提示
An error occurred while loading the web debug toolbar (404: Not Found).Do you want to open the profiler?
但是这样访问 http://localhost/Symfony/web/app_dev…. 与 http://localhost/Symfony/web/app_dev…. 都会返回404,求解
symfony2
问题已经解决,是因为nginx 默认不知从pathinfo模式, 配置一下就好了。
答案可能不正确,非常抱歉,还需验证一下
nginx没有配置pathinfo,配置后就可以了
打开Nginx的配置文件nginx.conf
在server中加入一下配置:
修改 location ~ .php# 为:^/(app|app_dev|config).php(/|$)
^/(app|app_dev|config)\.php(/|$)
添加pathinfo解析代码,其实就是正则匹配,后面接着添加如下代码
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
set $real_script_name $fastcgi_script_name;
set $path_info ””;
if ( $fastcgi_script_name ~ “^(.+?.php)(/.+)$”)
{
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
配置为完成如下
location ~ .php {
root /www/;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9090;
fastcgi_index index.php;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
set $path_info ””;
if ( $fastcgi_script_name ~ “^(.+?.php)(/.+)$”)
{
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
- 注意if ( ) 括号两边需要有空格隔开。
修改以后以后可以识别pathinfo但是symfony 仍然报错。暂时没解决。
看来是时候放大招了~ 四六级包过啊 哈哈哈
server {
listen 80;
server_name 192.168.1.120;
root /data/nginx/htdocs/cwz;
location / {
index index.php index.html;
root /data/nginx/htdocs/cwz;
}
index app.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /app_dev.php/$1;
}
location ~ \.php(/|$) {
# try_files $uri =404;
fastcgi_index app_dev.php;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
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;
include fastcgi_params;
}
}
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
}
正文完