7

我目前已将我的 Codeigniter rootindex.phpenvironment变量设置为development.

而且我还没有启用小 URL 模式。

我不喜欢/var/log/apache2/error.log每天夜以继日地检查!

希望我的 PHP 错误返回到页面。500 Internal error 实际上是可以用来显示错误的*HARD *est 方法。

请注意,我们正在使用默认配置的 Ubuntu 12.04 LTS 服务器。

4

2 回答 2

14

As mentioned in the comment I'm doubtful that this is CodeIgniter's issue. It's more likely that you simply have display_errors set to off in your php.ini.

If I remember correctly, CI's index.php contains a call to ini_set('error_reporting', ..); to change the default behaviour anyway, so you could always look in there first and see what's going on.

Just had a look, here's the default:

/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL.  For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit:  http://www.php.net/error_reporting
|
*/
    error_reporting(E_ALL);

If you simply add under there ini_set('display_errors', 1);, it should start working just fine. Obviously the best bet would be to add a switch for your environment to set these variables, I'm not sure why it's not like that already, but here's an example:

if (defined('ENVIRONMENT'))
{
    switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(E_ALL);
            ini_set('display_errors', 1);
            break;
        case 'production':
            error_reporting(0);
            ini_set('display_errors', 0);
            break;
    }
}
于 2013-01-05T14:21:15.507 回答
0

我遇到了同样的问题,我从 codeigniter 得到的唯一一件事就是一个 500 内部错误。(我的旧项目和全新安装也是如此)但有趣的部分是我的非 CI 项目仍然可以工作,其中主要包含 php。

写出错误的提示

ini_set('display_errors', 'On' / ,1)

由于某种原因解决了我的问题,我无权读取 codeigniter 核心文件。

在文件中添加 ' +r ' 解决了这个问题。

Rudi Visser
CarlosIPe
我感谢你们两位的解决方案。

于 2013-04-22T15:14:25.180 回答