簡體   English   中英

Symfony 2 + Nginx:無法加載Web調試工具欄(404:找不到)

[英]Symfony 2 + Nginx : can't load the web debug toolbar (404: Not Found)

我是Linux,PHP,Nginx和Symfony的新手(是的,這是一條漫長的路:)),並且在創建新的Symfony項目時遇到了麻煩。

問題

我在這里瀏覽了網絡和其他主題,但是在訪問app_dev.php無法處理以下消息:

An error occurred while loading the web debug toolbar (404: Not Found) Do you want to open the profiler?

如果單擊OKhttp://testsite.local/Symfony/web/app_dev.php/_profiler/f63f84重定向到http://testsite.local/Symfony/web/app_dev.php/_profiler/f63f84 ,這會導致404錯誤。

配置

我使用fpm重新安裝了Nginx,可以在à標准PHP站點上正常工作。

app.phpconfig.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;
    }
}

如果有人知道如何解決此問題,請告訴我。 任何幫助將不勝感激:)

謝謝 !

此Nginx配置應適用於您的開發環境

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文檔和您發布的配置

@Miro&@VEBERArnaud:伙計們,現在可以用了。
根據您的建議,這是解決方案:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM