CodeIgniter私有服务器上的系统路径不正确

时间:2014-01-15 02:28:10

标签: php xampp codeigniter-2

codeigniter项目上传到服务器时给出了以下错误。

  

您的系统文件夹路径似乎未正确设置。请   打开以下文件并更正:index.php

本地运作良好&在 000webhost.com 托管。

  

当上传到parallels的私人服务器时,会出现上述错误。

我的index.php如下。

<?php
define('ENVIRONMENT', 'development');

if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
    case 'development':
        error_reporting(E_ALL);
    break;

    case 'testing':
    case 'production':
        error_reporting(0);
    break;

    default:
        exit('The application environment is not set correctly.');
}
 }
$system_path = 'system';
$application_folder = 'application';


if (defined('STDIN'))
{
    chdir(dirname(__FILE__));
}

if (realpath($system_path) !== FALSE)
{
    $system_path = realpath($system_path).'/';
}

$system_path = rtrim($system_path, '/').'/';

if ( ! is_dir($system_path))
{
    exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}

define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('EXT', '.php');

// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));

// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));

// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));


// The path to the "application" folder
if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ( ! is_dir(BASEPATH.$application_folder.'/'))
    {
        exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}
 require_once BASEPATH.'core/CodeIgniter.php';

6 个答案:

答案 0 :(得分:1)

我更改了define('ENVIRONMENT', 'development');

if ($_SERVER['SERVER_ADDR'] == '192.168.0.1' || $_SERVER['HTTP_HOST'] == 'localhost')
{
    define('ENVIRONMENT', 'development');
}
else
{
    define('ENVIRONMENT', 'production');
}

对我有用。

来自here

的引用

答案 1 :(得分:0)

在根文件夹

上试试这个.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

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

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

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

假设 index.php 是您的索引页。

并更改config.php

$config['index_page'] = '';

答案 2 :(得分:0)

在我的情况下,我没有去弄乱.htaccess, 实际上在去做之前,正如上面的帖子所建议的那样, 我尝试了后来的部分,这正在改变

$config['index_page'] = 'index.php';

以下

$config['index_page'] = '';

它对我有用!

编辑添加更多信息~~~~~~~~~~~~~~~~~~~~~

我的CodeIgniter目录结构:

htdocs /
       |_ CI /
             |_ OnlineStoreApp /
                               |_ online_store_ci  // This is the CodeIgniter folder
                               |_ public_html /
                                              |_ css
                                              |_ js
                                              |_ fonts
                                              |_ .htaccess // see bellow for more details
                                              |_ index.php // see bellow for more details

我的.htaccess文件包含以下内容:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

我的index.php文件与CodeIgniter根文件夹提供的文件相同,但我必须在其中更改两行,因为我将其放在 public_html 目录中,而不是在原来的地方:

注意:index.php中查找以下两行,
  - $system_path
  - $application_folder
已对它们进行了编辑,以指出system目录和application目录所在的位置。

<?php

/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
 *
 * You can load different configurations depending on your
 * current environment. Setting the environment also influences
 * things like logging and error reporting.
 *
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
    define('ENVIRONMENT', 'development');
/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */

if (defined('ENVIRONMENT'))
{
    switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(E_ALL);
        break;

        case 'testing':
        case 'production':
            error_reporting(0);
        break;

        default:
            exit('The application environment is not set correctly.');
    }
}

/*
 *---------------------------------------------------------------
 * SYSTEM FOLDER NAME
 *---------------------------------------------------------------
 *
 * This variable must contain the name of your "system" folder.
 * Include the path if the folder is not in the same  directory
 * as this file.
 *
 */
    $system_path = '../online_store_ci/system';

/*
 *---------------------------------------------------------------
 * APPLICATION FOLDER NAME
 *---------------------------------------------------------------
 *
 * If you want this front controller to use a different "application"
 * folder then the default one you can set its name here. The folder
 * can also be renamed or relocated anywhere on your server.  If
 * you do, use a full server path. For more info please see the user guide:
 * http://codeigniter.com/user_guide/general/managing_apps.html
 *
 * NO TRAILING SLASH!
 *
 */
    $application_folder = '../online_store_ci/application';

/*
 * --------------------------------------------------------------------
 * DEFAULT CONTROLLER
 * --------------------------------------------------------------------
 *
 * Normally you will set your default controller in the routes.php file.
 * You can, however, force a custom routing by hard-coding a
 * specific controller class/function here.  For most applications, you
 * WILL NOT set your routing here, but it's an option for those
 * special instances where you might want to override the standard
 * routing in a specific front controller that shares a common CI installation.
 *
 * IMPORTANT:  If you set the routing here, NO OTHER controller will be
 * callable. In essence, this preference limits your application to ONE
 * specific controller.  Leave the function name blank if you need
 * to call functions dynamically via the URI.
 *
 * Un-comment the $routing array below to use this feature
 *
 */
    // The directory name, relative to the "controllers" folder.  Leave blank
    // if your controller is not in a sub-folder within the "controllers" folder
    // $routing['directory'] = '';

    // The controller class file name.  Example:  Mycontroller
    // $routing['controller'] = '';

    // The controller function you wish to be called.
    // $routing['function'] = '';


/*
 * -------------------------------------------------------------------
 *  CUSTOM CONFIG VALUES
 * -------------------------------------------------------------------
 *
 * The $assign_to_config array below will be passed dynamically to the
 * config class when initialized. This allows you to set custom config
 * items or override any default config values found in the config.php file.
 * This can be handy as it permits you to share one application between
 * multiple front controller files, with each file containing different
 * config values.
 *
 * Un-comment the $assign_to_config array below to use this feature
 *
 */
    // $assign_to_config['name_of_config_item'] = 'value of config item';



// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS.  DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------

/*
 * ---------------------------------------------------------------
 *  Resolve the system path for increased reliability
 * ---------------------------------------------------------------
 */

    // Set the current directory correctly for CLI requests
    if (defined('STDIN'))
    {
        chdir(dirname(__FILE__));
    }

    if (realpath($system_path) !== FALSE)
    {
        $system_path = realpath($system_path).'/';
    }

    // ensure there's a trailing slash
    $system_path = rtrim($system_path, '/').'/';

    // Is the system path correct?
    if ( ! is_dir($system_path))
    {
        exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
    }

/*
 * -------------------------------------------------------------------
 *  Now that we know the path, set the main path constants
 * -------------------------------------------------------------------
 */
    // The name of THIS file
    define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

    // The PHP file extension
    // this global constant is deprecated.
    define('EXT', '.php');

    // Path to the system folder
    define('BASEPATH', str_replace("\\", "/", $system_path));

    // Path to the front controller (this file)
    define('FCPATH', str_replace(SELF, '', __FILE__));

    // Name of the "system folder"
    define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));


    // The path to the "application" folder
    if (is_dir($application_folder))
    {
        define('APPPATH', $application_folder.'/');
    }
    else
    {
        if ( ! is_dir(BASEPATH.$application_folder.'/'))
        {
            exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
        }

        define('APPPATH', BASEPATH.$application_folder.'/');
    }

/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 *
 */
require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index.php */
/* Location: ./index.php */

希望这可能有助于那里的人!

CodeIgniter Rocks!

答案 3 :(得分:0)

如果您上传项目,请按以下步骤操作

  1. 确保您已上传应用系统 index.php .htaccess < / p>

  2. 使用托管数据库修改config/database.php

  3. 确保网址拼写,Cz LINUX主机区分大小写。

  4. 确保将所有资源上传到服务器。 (CSS,JS,图像等......)

  5. 希望这有助于你:)

答案 4 :(得分:0)

我有同样的问题,然后我创建控制器,我已经创建了索引方法,然后使用下面的命令调用cron文件,它正在为我工​​作。

wget domain_name/google_script -O /dev/null

google_script = "My controller class name"

这个解决方案适合我。

答案 5 :(得分:0)

在过去40多年的时间里,我从未见过如此糟糕的产品交付。互联网搜索解决配置/设计问题只会使解决方案的工作变得更糟。

试图使该产品正常工作是一场噩梦。这使得Spring Boot看起来是有史以来产品交付方面的最大改进!

如果您要强制使用SaaS,这是完成任务的方法。