CodeIgniter项目不适用于基于Linux的远程服务器

时间:2016-02-06 01:45:13

标签: php linux .htaccess codeigniter

我在Windows XAMPP上使用CodeIgniter开发了一个可以工作的项目。但是在基于Linux的远程服务器上不起作用。

我收到了错误:

  

无法加载请求的文件:home.php

控制器: home.php:

public function index(){
  $this->load->view('home');
}

htaccess的:

RewriteEngine on
RewriteCond $1 !^(index\\.php|resources|robots\\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

2 个答案:

答案 0 :(得分:1)

在codeIgniter 3 +版本上,如果出现以下错误,可以进行几项检查。

  • 错误404页面未找到
  • 无法加载请求的文件
  

先检查。

  • 确保您的文件名仅包含首字母大写
  • 确保您的班级名称仅包含首字母大写字母
  • 这也适用于模特。

警告:有时即使小写可能在某些localhost上运行某些其他操作系统,但是当文件或类是小写时它可能会导致错误,但对于每个人来说可能都不一样。

Controller

文件名: Home.php

<?php

class Home extends CI_Controller {

     public function __construct() {
        parent::__construct();
        $this->load->model('model_example');
     }

     public function index(){
        // $data['results'] = $this->model_example->get_results();
        $this->load->view('home');
     }
}

视图的文件夹结构

application

application > views > home.php

Models

文件名: Model_example.php

<?php

class Model_example extends CI_Model {

    public function get_results() {
      // Some Code Here.
    }
}

在你的config.php

$config['base_url'] = 'http://localhost/your_project_name/';

答案 1 :(得分:0)

不是直接上传codeigniter网站,而是应该能够使用Putty(http://www.putty.org/)之类的东西通过脚本安装新版本的Codeigniter,然后将您网站的文件添加到安装中。

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html

用于安装新版CI的脚本将根据您正在使用的Linux平台而有所不同。 wget用于ubuntu。