php CodeIgniter 500 内部服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7377876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:34:41  来源:igfitidea点击:

CodeIgniter 500 Internal Server Error

php.htaccesscodeigniterinternal-server-error

提问by acidburn23

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.

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

I run the site from http://localhost/myprojIt 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.

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

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

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

RewriteEngine On
RewriteBase /

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

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/ [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.

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

回答by tpae

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

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

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

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

  1. Error in script (PHP misconfigurations, missing packages, etc...)
  2. PHP "Fatal Errors"
  1. 脚本错误(PHP 配置错误、缺少包等...)
  2. PHP“致命错误”

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

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

回答by Luqmaan

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.

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

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.

问题是较旧的 CodeIgniter 版本(如 1.7 及更低版本)不适用于 PHP 5.3。解决方案是切换到 PHP 5.2 或更旧的版本。

回答by chrishall78

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

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

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

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

回答by Mustapha

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

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

LoadModule rewrite_module modules/mod_rewrite.so 

回答by Pierre Alexandre

Try this to your .htaccess file:

试试这个到你的 .htaccess 文件:

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

回答by Samir Rahimy

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

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

回答by Alvin Jose

if The wampserver Version 2.5 then change apache configuration as

如果 wampserver 版本 2.5 然后将 apache 配置更改为

httpd.conf (apache configuration file):From

httpd.conf(apache 配置文件):来自

#LoadModule rewrite_module modules/mod_rewrite.so** 

To ,delete the #

,删除#

LoadModule rewrite_module modules/mod_rewrite.so** 

this working fine to me

这对我来说很好用

回答by Paritosh

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

回答by Aaron W.

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

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

回答by Chris GW Green

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.

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

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

干杯