Codeigniter在localhost中显示空白页面

问题描述 投票:1回答:3

我从Bitbucket克隆了一个应用程序,当通过localhost运行应用程序时,它显示一个完整的空白页面。当我从他们的网站下载一个新的codeigniter项目并运行时,它工作正常,没有问题。但是当我运行这个拉动项目时,它只显示空白页面而没有错误,一切都是空白的。

我在Ubuntu 16.04中使用php 7.0版工作

同一个项目在另一个系统中工作正常,配置与上面说的相同但是当在另一个系统中使用new时,它不起作用并显示一个空白页面。

基本网址是$config['base_url'] = 'http://localhost/school-erp/';

Index.php文件看起来像,

switch (ENVIRONMENT)
{
    case 'development':
        error_reporting(-1);
        ini_set('display_errors', 1);
    break;

    case 'testing':
    case 'production':
        ini_set('display_errors', 0);
        if (version_compare(PHP_VERSION, '5.3', '>='))
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
        }
        else
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
        }
    break;

    default:
        header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
        echo 'The application environment is not set correctly.';
        exit(1); // EXIT_ERROR
}

设定模型如下,

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Setting_model extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    /**
     * This funtion takes id as a parameter and will fetch the record.
     * If id is not provided, then it will fetch all the records form the table.
     * @param int $id
     * @return mixed
     */
    public function get($id = null) {

        $this->db->select('sch_settings.id,sch_settings.lang_id,sch_settings.is_rtl,sch_settings.timezone,
          sch_settings.name,sch_settings.email,sch_settings.phone,languages.language,
          sch_settings.address,sch_settings.dise_code,sch_settings.date_format,sch_settings.currency,sch_settings.currency_symbol,sch_settings.start_month,sch_settings.session_id,sch_settings.image,sessions.session'
        );
        $this->db->from('sch_settings');
        $this->db->join('sessions', 'sessions.id = sch_settings.session_id');
        $this->db->join('languages', 'languages.id = sch_settings.lang_id');
        if ($id != null) {
            $this->db->where('sch_settings.id', $id);
        } else {
            $this->db->order_by('sch_settings.id');
        }
        $query = $this->db->get();
        if ($id != null) {
            return $query->row_array();
        } else {
            return $query->result_array();
        }
    }

    /**
     * This function will delete the record based on the id
     * @param $id
     */
    public function remove($id) {
        $this->db->where('id', $id);
        $this->db->delete('sch_settings');
    }

    /**
     * This function will take the post data passed from the controller
     * If id is present, then it will do an update
     * else an insert. One function doing both add and edit.
     * @param $data
     */
    public function add($data) {
        if (isset($data['id'])) {
            $this->db->where('id', $data['id']);
            $this->db->update('sch_settings', $data);
        } else {
            $this->db->insert('sch_settings', $data);
            return $this->db->insert_id();
        }
    }

    public function getCurrentSession() {
        $session_result = $this->get();
        return $session_result[0]['session_id'];
    }

    public function getCurrentSessionName() {
        $session_result = $this->get();
        return $session_result[0]['session'];
    }

    public function getCurrentSchoolName() {
        $session_result = $this->get();
        return $session_result[0]['name'];
    }

    public function getStartMonth() {
        $session_result = $this->get();
        return $session_result[0]['start_month'];
    }

    public function getCurrentSessiondata() {
        $session_result = $this->get();
        return $session_result[0];
    }

    public function getDateYmd() {
        return date('Y-m-d');    }

    public function getDateDmy() {
        return date('d-m-Y');
    }

}

可能是什么错误,并有助于解决它。

php codeigniter php-7
3个回答
1
投票

case 'production':中,在index.php中将ini_set('display_errors', 0);更改为ini_set('display_errors', 1);


2
投票

你需要检查几件事:

  • base_url
  • htaccess RewriteBase
  • 权限
  • 在index.php中添加error_reporting(1)并查看报告的错误

1
投票

很多事情都可能发生:

1)您的项目根标签上必须有.htaccess文件(在本例中为school-erp)。打开.htaccess文件并粘贴:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) school-erp/$1$2 [R=301,NE,L]

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

2)检查您的database.php文件。你可以在school-erp - > application - > config - > database.php找到它

非常重要的是,此文件中的相同数据库名称,密码和用户以及DBMS上使用这些相同参数创建的数据库非常重要。请记住,如果您在database.php上有一个当前与您在DBMS上的内容不匹配的配置字符串,则codeigniter将不会显示任何页面。

3)以root用户身份打开终端,然后通过以下方式将目录更改为项目的当前路径:

cd var/www/

然后,您必须为school-erp文件夹及其中包含的所有文件夹提供必要的权限。您可以使用此说明执行此操作:

chmod 667 school-erp -R

小心你给你的文件的permision代码... chmod 777不适合生产环境(我甚至不在我的本地主机上使用它)。

4)如果你有这个文件夹结构,你当前的base_url将会工作(我将它作为路径发布):

var/www/school-erp

我为什么这么说?因为某些服务器instalations带有额外的文件夹级别。该文件夹通常称为“html”。如果发生这种情况,路径将更改为:

var/www/html/school-erp

这意味着您还需要更改base_url。

5)当你输入到项目的索引(localhost / school-erp)时,在其他系统中检查浏览器的导航栏如果它在url中没有出现“index.php”则意味着服务器正在重写网址所以你必须按照步骤1)我发布这个答案加上打开a2enmod重写apache服务器。

© www.soinside.com 2019 - 2024. All rights reserved.