我有Symfony2的问题.一切正常,有一天……开始出现问题……
当我打开一个页面时,我得到错误500.服务器返回此错误,而不是Symfony.
如果我刷新,我显示页面没有错误.
但是,当我打开一个新页面(新网址,同一网站)时,错误再次出现.
我试图重新加载apache.我尝试删除所有缓存和日志.
我的控制台文件,app.PHP文件,app_dev.PHP文件已取消注释umask(0000).
当我遇到错误时,这是symfony2日志的最后一行:
[2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "JMS\I18nRoutingBundle\EventListener\CookieSettingListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse". [] [] [2015-09-04 11:20:57] security.DEBUG: Write SecurityContext in the session [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\ChromePHPHandler::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\EsiListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\SaveSessionListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse". [] [] [2015-09-04 11:20:57] event.DEBUG: Notified event "kernel.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []
apache错误日志:
[Fri Sep 04 11:24:49 2015] [error] [client my.ip.here] Premature end of script headers: app_dev.PHP
当我使用app.PHP时,prod中不存在这个问题
系统日志没有关于此的内容.我在同一台服务器上的其他网站上没有问题.我没有硬盘空间问题.
有人有想法吗?谢谢
<?PHP use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Debug\Debug; // If you don't want to setup permissions the proper way,just uncomment the following PHP line // read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information umask(0000); // This check prevents access to debug front controllers that are deployed by accident to production servers. // Feel free to remove this,extend it,or make something more sophisticated. if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !in_array(@$_SERVER['REMOTE_ADDR'],array('127.0.0.1','xxx.xxx.xxx.xxx')) ) { header('HTTP/1.0 403 Forbidden'); exit($_SERVER['REMOTE_ADDR'].' : You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } $loader = require_once __DIR__.'/../app/bootstrap.PHP.cache'; Debug::enable(); require_once __DIR__.'/../app/AppKernel.PHP'; $kernel = new AppKernel('dev',true); $kernel->loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request,$response);
对于apache配置,这是isp配置配置,我刚为这个网站添加了这个:
Apache指令:
DocumentRoot /var/www/clients/client2/web56/web/symfony/web/ FcgidMaxRequestLen 20000000
PHP.ini:
apc.shm_size = 256M realpath_cache_size = 4096k realpath_cache_ttl=7200 session.auto_start = 0 xdebug.remote_autostart=0 xdebug.remote_enable=0 xdebug.profiler_enable=0
在config_dev.yml中,如果我从monolog配置中删除firePHP和chromePHP,问题就解决了.
我不认为这是一个很好的解决方案,任何人都有其他想法?
我在config_dev.yml中评论了firePHP和chromePHP:
原文链接:https://www.f2er.com/php/137958.htmlimports: - { resource: config.yml } framework: router: resource: "%kernel.root_dir%/config/routing_dev.yml" strict_requirements: true profiler: { only_exceptions: false } web_profiler: toolbar: true intercept_redirects: false monolog: handlers: main: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug # firePHP: # type: firePHP # level: info # chromePHP: # type: chromePHP # level: info assetic: use_controller: true #swiftmailer: # delivery_address: me@example.com