2015-11-25 40 views
1

我想將Symfony2安裝到一個現有的項目,所以我從頭開始設置一切。我在Symfony2中不斷收到「500內部服務器錯誤」。 Web服務器日誌中沒有日誌,Symfony2甚至不在日誌目錄內創建日誌文件(我使用AppKernel將其設置爲ROOT/var/logs)。下面是我的配置:symfony2給內部服務器錯誤,沒有日誌

parameters: 
    app_locales: en|fr|de|es|cs|nl|ru|uk|ro|pt_BR|pl|it|ja|id|ca 
    app.notifications.email_sender: [email protected] 
    locale: en 
    secret: "MaEKo3wZsCMIz7tR1uBCyIDGhvJU0EbnYgl0YlhognA" 

framework: 
    ide: sublime 

translator:  { fallback: "%locale%" } 
secret:   "%secret%" 
router: 
    resource: "%kernel.root_dir%/config/routes.yml" 
    strict_requirements: ~ 
form:   ~ 
csrf_protection: ~ 
validation:  { enable_annotations: true } 
templating: 
    engines: ['twig'] 
default_locale: "%locale%" 
trusted_hosts: ~ 
trusted_proxies: ~ 
session: 
    handler_id: ~ 
fragments:  ~ 
http_method_override: true 

twig: 
    debug:   "%kernel.debug%" 
    strict_variables: "%kernel.debug%" 


# routes.yml 

homepage: 
    path:/
    defaults: 
     _controller: FrameworkBundle:Controller:template 
     template: default/homepage.html.twig 

這裏是AppKernel.php:

class AppKernel extends Kernel { 

    public function registerBundles() { 
     return [ 
      new Symfony\Bundle\FrameworkBundle\FrameworkBundle, 
      new Symfony\Bundle\SecurityBundle\SecurityBundle, 
      new Symfony\Bundle\TwigBundle\TwigBundle, 
      new Symfony\Bundle\DebugBundle\DebugBundle, 
      new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle 
     ]; 
    } 

    public function getCacheDir() { 
     return $this->rootDir.'/../var/cache'; 
    } 

    public function getLogDir() { 
     return $this->rootDir.'/../var/logs'; 
    } 

    public function registerContainerConfiguration(LoaderInterface $loader) { 
     $loader->load(__DIR__.'/config/config.yml'); 
    } 

} 

缺少什麼我在這裏?

+0

最有可能您的Web服務器無法將請求傳遞給symfony的。也許在其配置中存在備用日誌位置,或者其日誌記錄已關閉。追捕這種情況的最好方法是讓Web服務器自己登錄到可以訪問的位置並找出發生的事情。 – Cfreak

+0

這是一個內部Symfony2的東西,現在一切正常。 – Gasim

+0

你檢查了你的php日誌嗎?你也許可以檢查你的web服務器的日誌(例如,如果你的symfony應用程序在你的配置文件中使用了nginx的'error_log')。我也會檢查你的'php.ini',看看'display_errors'是否設置爲on。如果你仍然有問題,你可以把代碼列在你的'app_dev.php'裏面(這裏是http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display)在頂部。最後,它可能只是寫權限,所以你可以檢查'app/logs'文件夾是否可以通過'www-data'寫入 – mickadoo

回答

0

我挖了Symfony2的源代碼,發現它在發送之前捕捉到異常。因此,爲了調試的目的,我改變了我的處理代碼:

$response = $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false);