CodeIgniter 500 内部服务器错误

发布于 2024-12-04 09:15:42 字数 878 浏览 5 评论 0原文

我下载了一个使用 CodeIgniter 编写的 PHP 脚本。当我从本地主机运行它时,进入管理文件夹时,它再次显示本地主机。此外,当从我的 Web 主机运行时,它显示 500 内部服务器错误。

我从 http://localhost/myproj 运行该网站,它有效。然后,当我尝试转到位于 http://localhost/myproj/administrator 的管理页面时,它会给出 500 内部服务器错误。

我在这里读到这可能是由于 .htaccess 文件中的错误代码造成的。这是我现在的 .htaccess 文件

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

请帮助我。我知道这可能是一个非常小的问题,但我无法找到错误。

I downloaded a PHP script written using CodeIgniter. when I run it from the localhost, on going to the admin folder, it shows localhost again. Also when running from my web host, it shows a 500 Internal Server Error.

I run the site from http://localhost/myproj It works. Then when I try to go to the admin page which is at http://localhost/myproj/administrator, it gives a 500 Internal Server Error.

I read here that this might be due to a wrong code in the .htaccess file. This is my present .htaccess file

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

Please help me. I know it might be a very small problem, but I'm unable to find the error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

前事休说 2024-12-11 09:15:43

聚会已经很晚了,但是,我认为解决 CodeIgniter 中 500 个内部服务器错误的最佳方法是在 config 文件夹中的 Config.php 文件中启用错误日志功能,并设置一个阈值,即 $config['log_threshold'] = 1,2,3,4,具体取决于您要查看的日志。

Pretty late to the party but, i think the best approach to 500 internal server errors in CodeIgniter would be to enable the error log functionality in the Config.php file in the config folder and set a threshold value i.e. $config['log_threshold'] = 1,2,3,4 depending on the logs you want to view.

眼前雾蒙蒙 2024-12-11 09:15:43

这可能与此线程不再相关,但希望对某人有所帮助。
在过去的一个小时里,我遇到了 500 个错误,因为我的(蹩脚)服务器上运行的 php 版本不支持控制器返回的数组。看起来微不足道,但具有代码点火器错误的特征。

我不得不使用:

class emck_model extends CI_Model {

    public function getTiles(){

        return array(...);

    }

} 

而不是

class emck_model extends CI_Model {

    public function getTiles(){

        return [...];

    }

}

干杯

This probably isn't relevant any more to this thread, but hopefully helpful to somebody.
I've had 500 errors for the past hour as I had a controller return an array not supported by the php version ran on my (crappy) server. Seems trivial but had the hallmarks of a codeigniter error.

I had to use:

class emck_model extends CI_Model {

    public function getTiles(){

        return array(...);

    }

} 

Instead of

class emck_model extends CI_Model {

    public function getTiles(){

        return [...];

    }

}

Cheers

你另情深 2024-12-11 09:15:43

这对我来说很好用

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >

This works fine for me

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
真心难拥有 2024-12-11 09:15:43

如果您使用本地服务器,当基本模块未启用时,Wampserver 中会遇到此问题。

您可以通过以下方式启用它们:

左键单击 Wampsever 图标

转至 APACHE ->; APACHE MODULES

向下滚动并找到“rewrite_module”和“headers_module”

然后将它们标记为选中

它将自动重新启动。完毕。

输入图片此处描述

If your are using local server, this problem is faced in Wampserver when the essential modules are not enable.

You can Enable them with:

Left click on Wampsever icon

Go to APACHE -> APACHE MODULES

scroll down and find "rewrite_module" and "headers_module"

Then mark them check

It will restart automatically. Done.

enter image description here

风为裳 2024-12-11 09:15:42

500 错误的问题(使用 CodeIgniter),使用不同的 apache 设置,当 PHP 配置出现错误时,它会显示 500 错误。

以下是如何使用 CodeIgniter 触发 500 错误:

  1. 脚本错误(PHP 配置错误、缺少软件包等)
  2. PHP“致命错误”

请检查您的 apache 错误日志,其中应该有一些有趣的信息。

The problem with 500 errors (with CodeIgniter), with different apache settings, it displays 500 error when there's an error with PHP configuration.

Here's how it can trigger 500 error with CodeIgniter:

  1. Error in script (PHP misconfigurations, missing packages, etc...)
  2. PHP "Fatal Errors"

Please check your apache error logs, there should be some interesting information in there.

忱杏 2024-12-11 09:15:42

为了防止其他人偶然发现这个问题,我继承了一个旧的 CodeIgniter 项目,并且在安装它时遇到了很多麻烦。

我浪费了大量时间尝试创建该网站的本地安装并尝试了所有方法。最后,解决方案很简单。

问题是较旧的 CodeIgniter 版本(如 1.7 及更低版本)无法与 PHP 5.3 一起使用。解决方案是切换到 PHP 5.2 或更旧的版本。

Just in case somebody else stumbles across this problem, I inherited an older CodeIgniter project and had a lot of trouble getting it to install.

I wasted a ton of time trying to create a local installation of the site and tried everything. In the end, the solution was simple.

The problem is that older CodeIgniter versions (like 1.7 and below), don't work with PHP 5.3. The solution is to switch to PHP 5.2 or something older.

去了角落 2024-12-11 09:15:42

您正在尝试从站点 URL 中删除 index.php,对吗?

尝试将 $config['uri_protocol'] 设置为 REQUEST_URI 而不是 AUTO

You're trying to remove index.php from your site URL's, correct?

Try setting your $config['uri_protocol'] to REQUEST_URI instead of AUTO.

撕心裂肺的伤痛 2024-12-11 09:15:42

确保您的根 index.php 文件具有正确的权限,其权限必须是 07550644

Make sure your root index.php file has the correct permission, its permission must be 0755 or 0644

无所谓啦 2024-12-11 09:15:42

对您的 .htaccess 文件尝试以下操作:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >

Try this to your .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
油饼 2024-12-11 09:15:42

删除httpd.conf(apache配置文件)中的注释:

LoadModule rewrite_module modules/mod_rewrite.so 

remove comment in httpd.conf (apache configuration file):

LoadModule rewrite_module modules/mod_rewrite.so 
不喜欢何必死缠烂打 2024-12-11 09:15:42

每当我在子目录中运行 CodeIgniter 时,我都会为其设置 RewriteBase 。尝试将其设置为 /myproj/ 而不是 /

Whenever I run CodeIgniter in a sub directory I set the RewriteBase to it. Try setting it as /myproj/ instead of /.

夜访吸血鬼 2024-12-11 09:15:42

我知道我迟到了,但这会对某人有所帮助。

检查重写引擎是否启用

如果没有,启用重写引擎并重新启动服务器。

sudo a2enmod rewrite
sudo service apache2 restart

I know I am late, but this will help someone.

Check if rewrite engine is enabled.

If not, enable rewrite engine and restart server.

sudo a2enmod rewrite
sudo service apache2 restart
枕头说它不想醒 2024-12-11 09:15:42

如果 wampserver 版本 2.5,则将 apache 配置更改为

httpd.conf(apache 配置文件):

#LoadModule rewrite_module modules/mod_rewrite.so** 

到 ,删除 #

LoadModule rewrite_module modules/mod_rewrite.so** 

这对我来说工作正常

if The wampserver Version 2.5 then change apache configuration as

httpd.conf (apache configuration file):
From

#LoadModule rewrite_module modules/mod_rewrite.so** 

To ,delete the #

LoadModule rewrite_module modules/mod_rewrite.so** 

this working fine to me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文