簡體   English   中英

Codeigniter在本地主機中顯示空白頁

[英]Codeigniter displays a blank page in localhost

我已經從Bitbucket克隆了一個應用程序,當通過localhost運行該應用程序時,它會顯示一個完整的空白頁。 當我從他們的網站下載一個新的codeigniter項目並運行時,它工作正常,沒有問題。 但是,當我運行此拉出的項目時,它僅顯示空白頁且沒有錯誤,所有內容均為空白。

我正在使用PHP 7.0Ubuntu 16.04中工作

同一項目在具有與上述相同配置的另一個系統中可以正常工作,但是在另一個系統中插入新項目時,它將不起作用並顯示空白頁。

基本網址為$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');
    }

}

錯誤可能是什么,請幫忙解決。

您需要檢查幾件事:

  • base_url
  • htaccess RewriteBase
  • 權限
  • 在index.php中添加error_reporting(1)並查看正在報告的錯誤

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

很多事情可能正在發生:

1)您的項目根目錄標簽(在這種情況下為school-erp)必須具有.htaccess文件。 打開.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->應用程序->配置-> database.php中找到它

在此文件中使用相同的數據庫名稱,密碼和用戶非常重要,並且在DBMS上使用相同的參數創建數據庫。 請記住,如果您在database.php上的配置字符串當前與DBMS上的配置字符串不匹配,則codeigniter不會顯示任何頁面。

3)以root用戶身份打開終端,然后通過以下方式將目錄更改為項目的當前路徑:

cd var/www/

然后,您必須將必要的權限分配給school-erp文件夾,並將其全部包含在其中。 您可以按照以下說明進行操作:

chmod 667 school-erp -R

小心輸入文件的滲透代碼... chmod 777不適合生產環境(我甚至不在本地主機上使用它)。

4)如果您具有以下文件夾結構,則當前的base_url將起作用(我將其發布為路徑):

var/www/school-erp

我為什么這么說呢? 因為某些服務器安裝附帶了額外的文件夾級別。 該文件夾通常稱為“ html”。 如果發生這種情況,路徑將更改為:

var/www/html/school-erp

這意味着您也需要更改base_url。

5)輸入項目索引(localhost / school-erp)時,請在其他系統中檢查瀏覽器的導航欄,如果該URL中未顯示“ index.php”,則表示服務器正在重寫網址,因此您將必須執行步驟1)我在此答案上發布並打開apache服務器的a2enmod重寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM