14

尝试打开时收到此错误消息

/app_dev.php

An error occurred while loading the web debug toolbar (404: Not Found).

Do you want to open the profiler?

当我单击确定时,我收到错误:

app_dev.php/_profiler/5053258a822e1

404 Not found

我正在使用 nginx

非常感谢您的帮助。

编辑:这是错误日志:

[error] 18369#0: *9 open() "/var/www/Symfony/web/app_dev.php/_wdt/5056f875afc98" failed (20: Not a directory), client: 127.0.0.1, server: symfony, request: "GET /app_dev.php/_wdt/5056f875afc98 HTTP/1.1", host: "symfony", referrer: "http://symfony/app_dev.php"
[error] 18369#0: *9 open() "/var/www/Symfony/web/404" failed (2: No such file or directory), client: 127.0.0.1, server: symfony, request: "GET /app_dev.php/_wdt/5056f875afc98 HTTP/1.1", host: "symfony", referrer: "http://symfony/app_dev.php"

编辑2:

当我尝试访问 app_dev.php 时,页面打开但没有工具栏,当我尝试使用 app_dev.php/ 时,我得到了

**Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused. **

错误。

4

7 回答 7

11

我知道这不完全是你问的,但可能会帮助未来搜索这个问题的人,就像@yvoyer 建议的那样,我的问题也是斜杠,我的服务器使用了 nginx 和 fpm,并且在 nginx // 中不 euqal / ,所以我不得不对我的虚拟主机 conf 进行一些修复,之后它运行良好。我只是将conf粘贴给需要它的人,或者建议一个更好的。

    location / {
            try_files $uri @pass_to_symfony;
    }

    location ~ /app_dev.php/ {
            try_files $uri @pass_to_symfony_dev;
    }

    location @pass_to_symfony{
            rewrite ^ /app.php?$request_uri last;
    }

    location @pass_to_symfony_dev{
            rewrite ^ /app_dev.php?$request_uri last;
    }

    location ~ ^/app(_dev)?\.php($|/) {
            include fastcgi_params;
            fastcgi_pass   unix:/var/run/php5-fpm.sock; # replace with your sock path
    }
于 2013-03-08T16:24:52.723 回答
3

我有同样的错误,但我发现在我输入时输出了消息,app_dev.php/但在请求时没有输出app_dev.php(注意尾部斜杠/)。

我认为它与路由器有关,但这只是一个有根据的猜测

于 2012-11-30T19:02:58.560 回答
1

我的错误与 Nginx 配置有关(使用 symfony 3.1),我刚刚从 Symfony 编辑了 Nginx 的推荐配置:

http://symfony.com/doc/current/setup/web_server_configuration.html

所以,也许是因为符号链接,我不知道。

我将一小部分复制到 Nginx 默认配置并进行编辑以匹配所有 .php:

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }


    # Symfony
    location ~ \.php(/|$) {
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #   include snippets/fastcgi-php.conf;
    #
    #   # With php7.0-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php7.0-fpm:
    #   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}

}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}

对于生产服务器,我建议坚持 Symfony 推荐。

于 2016-11-20T05:01:34.927 回答
0

要在 Symfony2 页面中以开发人员模式显示 Web 调试工具栏,应具有有效的 HTML。

于 2012-09-14T12:51:28.957 回答
-1

它发生在我的开发环境中,所以我在我的虚拟主机配置文件中评论了指令 DirectoryIndex,所以现在我进入我的应用程序:http://127.0.0.1/app_dev.php 并且没有更多关于探查器的错误!我使用 Symfony 2.3.x。

于 2014-06-01T20:20:39.677 回答
-1

我找到了解决方案(或多或少)。我采用了另一个现有的 Symfony 项目,现在一切正常。我真的不知道为什么 Symfony 标准版本在我的情况下不起作用......如果有人需要空的 symfony 项目,我可以上传存档。

编辑:这里是工作 Symfony 2.0 的模板:http ://www.megafileupload.com/en/file/372986/Symfony-tpl-zip.html

于 2012-09-17T14:21:57.003 回答
-3

请尝试注意您的.htaccess,我也遇到了这个问题,我解决了我的问题。

    <IfModule mod_rewrite.c>
    RewriteEngine On
        RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    </IfModule>

    <IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the startpage to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
    </IfModule>
于 2013-06-04T10:41:02.903 回答