首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Symfony 2+ Nginx :无法加载web调试工具栏(404:未找到)

Symfony 2+ Nginx :无法加载web调试工具栏(404:未找到)
EN

Stack Overflow用户
提问于 2016-04-20 20:48:46
回答 2查看 2.6K关注 0票数 2

我是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.phpconfig.php都工作得很好(在config.php中没有发现问题)。

下面是我的Symfony项目的路径:/srv/www/testsite.local/public_html/Symfony/

在这里,我的(基本) Nginx (/etc/nginx/sites-available/testsite.local)配置:

代码语言:javascript
运行
复制
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;
    }
}

如果有人知道如何解决这个问题,请告诉我。如能提供任何帮助,将不胜感激:)

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-04-22 12:38:56

@Miro & @VEBERArnaud : Thx伙计们,现在起作用了。

以下是根据您的建议提出的解决方案:

代码语言:javascript
运行
复制
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;
    }
}
票数 1
EN

Stack Overflow用户

发布于 2016-04-20 23:00:06

这个nginx配置应该适用于dev环境。

代码语言:javascript
运行
复制
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文档和您发布的配置的混合。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36754900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档