2012-09-14 8 views
13

sto ottenendo questo messaggio di errore quando si tenta di aprireSymfony 2: errore 404 Not Found quando tryes per aprire /app_dev.php

/app_dev.php

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

Do you want to open the profiler? 

Quando clicco ok, io sono ottenendo quindi l'errore:

app_dev.php/_profiler/5053258a822e1 

e

404 Not found 

Sto usando nginx

Grazie mille per il vostro aiuto.

EDIT: Ecco il log degli errori:

[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" 

EDIT 2:

Quando provo ad accedere app_dev.php la pagina si apre, ma senza la barra degli strumenti e quando provo con app_dev.php/Sto ottenendo il

**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. ** 

errore.

+1

Puoi pubblicare il tuo log degli errori di nginx? (! Non solo ciò che viene stampato nel browser) – Florent

+0

Grazie Florent, ho cambiato la mia domanda –

+0

contrario, controllare la mia risposta qui: http://stackoverflow.com/a/30313196/1700429 – Dahab

risposta

10

So che questo non è esattamente quello che hai chiesto, ma potrebbe aiutare le persone future che cercano di questo problema, come ha suggerito @yvoyer, il mio problema era la barra finale, il mio server usava nginx e fpm, e in nginx // non euqal /, quindi ho dovuto fare un po 'di correzioni sul mio host virtuale conf e ha funzionato bene dopo. Dovrò semplicemente incollare il conf per chi ne ha bisogno o suggerirne uno migliore.

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 
    } 
0

Per visualizzare la barra degli strumenti di debug Web in modalità sviluppatore nella pagina Symfony2 deve essere presente HTML valido.

+0

Grazie @Rafal, ma sto provando ad aprire il file app_dev.php, viene dal Sito Web di Symfony. Come risolvere questo problema? –

-1

Ho trovato la soluzione (più o meno). Ho preso un altro progetto Symfony esistente e ora funziona tutto bene. Non so davvero perché la versione standard di Symfony non funzioni nel mio caso ... Se somebady ha bisogno del progetto symfony vuoto, posso caricare l'archivio.

EDIT: qui è il modello del lavoro Symfony 2.0: http://www.megafileupload.com/en/file/372986/Symfony-tpl-zip.html

+0

per favore carica l'archivio, ho lo stesso problema – tesmojones

+2

Ecco il modello di Symfony. Divertiti: http://www.megafileupload.com/en/file/372986/Symfony-tpl-zip.html Se trovi questo utile, per favore upvote. Grazie. –

3

ho avuto lo stesso errore, ma ho scoperto che il messaggio era uscita quando ho digitato app_dev.php/, ma non quando si richiede app_dev.php (Si noti la barra finale /).

Io penso che abbia a che fare con il router, ma il suo solo un'ipotesi plausibile

-3

prova a prestare attenzione al tuo .htaccess, ho avuto questo problema e ho risolto il mio.

<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> 
+5

Si prega di leggere l'intero post prima: "Sto usando nginx Grazie mille per il vostro aiuto." Mentre il tuo commento è appropriato per APACHE, farà impazzire la gente. – Zjoia

-1

E 'accaduto nella mia dev environnement, così io commento la direttiva DirectoryIndex nel mio file di configurazione vhost, così ora ho al mio app con: http://127.0.0.1/app_dev.php E niente più errori circa il profiler! Io uso Symfony 2.3.x.

0

Il mio errore era correlato alla configurazione di Nginx (usando symfony 3.1), e ho appena modificato la configurazione consigliata per Nginx da Symfony:

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

Così, forse era a causa di link simbolici, non lo so.

ho copiato una piccola parte di Nginx configurazione di default e modificato per corrispondere a tutti i .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; 
# } 
#} 

Suggerirei attaccare raccomandazione Symfony per un server di produzione.

Problemi correlati