我是Linux、PHP、Nginx & Symfony的新手(是的,这将是一条漫长的道路:),我在创建一个新的Symfony项目时遇到了麻烦。
问题
我在这里浏览了web和其他主题,但访问app_dev.php
时无法处理以下消息:
An error occurred while loading the web debug toolbar (404: Not Found) Do you want to open the profiler?
如果单击OK
,就会在http://testsite.local/Symfony/web/app_dev.php/_profiler/f63f84
上重定向,从而导致404错误。
配置
我有一个新的安装Nginx与fpm,工作良好的标准PHP网站。
app.php
和config.php
都工作得很好(在config.php中没有发现问题)。
下面是我的Symfony项目的路径:/srv/www/testsite.local/public_html/Symfony/
在这里,我的(基本) Nginx (/etc/nginx/sites-available/testsite.local
)配置:
server {
server_name testsite.local;
access_log /srv/www/testsite.local/logs/access.log;
error_log /srv/www/testsite.local/logs/error.log;
root /srv/www/testsite.local/public_html;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
如果有人知道如何解决这个问题,请告诉我。如能提供任何帮助,将不胜感激:)
谢谢!
发布于 2016-04-22 12:38:56
@Miro & @VEBERArnaud : Thx伙计们,现在起作用了。
以下是根据您的建议提出的解决方案:
server {
server_name testsite.local;
access_log /srv/www/testsite.local/logs/access.log;
error_log /srv/www/testsite.local/logs/error.log;
root /srv/www/testsite.local/public_html;
location / {
# try to serve file directly, fallback to app_dev.php
try_files $uri /Symfony/web/app_dev.php$is_args$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
发布于 2016-04-20 23:00:06
这个nginx配置应该适用于dev环境。
server {
server_name testsite.local;
root /srv/www/testsite.local/public_html;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
error_log /srv/www/testsite.local/logs/error.log;
access_log /srv/www/testsite.local/logs/access.log;
}
如果没有检查您的fastcgi_params (/etc/nginx/fastcgi_params
)
别忘了重新加载nginx服务器
--
此配置是symfony文档和您发布的配置的混合。
https://stackoverflow.com/questions/36754900
复制相似问题