我对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中不存在这个问题syslog没有关于此的内容。我在同一台服务器上的其他网站上没有问题。我没有硬盘空间问题。
有人有想法吗? THX
app_dev.php文件:
<?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,问题就解决了。 我不认为这是一个很好的解决方案,任何人都有其他想法?
答案 0 :(得分:14)
我在 config_dev.yml 中评论了 firephp 和 chromephp :
imports:
- { 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