gpt4 book ai didi

php - Symfony2 app_dev.php 只有错误 500 脚本过早结束

转载 作者:可可西里 更新时间:2023-11-01 12:30:12 26 4
gpt4 key购买 nike

我对 Symfony2 有疑问。一切正常,有一天……开始出现问题……

当我打开一个页面时,我得到错误 500。服务器返回这个错误,而不是 Symfony。如果我刷新,我显示页面没有错误。但是当我打开一个新页面(新 url,同一个站点)时,错误又来了。

我试图重新加载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 中不存在该问题

系统日志中没有关于此的行。我在同一台服务器上的其他网站上没有问题。我没有硬盘空间问题。

有人有想法吗?谢谢


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 config 配置,我刚刚为这个网站添加了这个:

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 中评论了 firephpchromephp :

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

关于php - Symfony2 app_dev.php 只有错误 500 脚本过早结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32394634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com