新网Logo
首页>虚机资讯>

CI框架apache相关设置 开发模式 生产模式自动判断

登录 注册

CI框架apache相关设置 开发模式 生产模式自动判断

  • 来源:
  • 更新日期:2018-04-25

摘要:本地测试环境中 apahche httpd-vhosts.conf 中添加虚拟主机例如 test.demo.com 增加变量 SetEnv CI_ENV \"development\" 本地hosts文件 增加对应 ip 如127.0.0.1  test.demo.com CI application config 文件夹中 config.php文件 添加以下信息 switch

本地测试环境中

timg (1).jpg

apahche httpd-vhosts.conf 中添加虚拟主机例如 test.demo.com

增加变量

SetEnv CI_ENV "development"

本地hosts文件 增加对应 ip 如127.0.0.1 test.demo.com

CI application config 文件夹中 config.php文件

添加以下信息
switch (ENVIRONMENT)
{
case \'development\':
$config[\'base_url\'] = \'test.demo.com\';
break;
case \'production\':
$config[\'base_url\'] = \'www.demo.com\';
break;
}

数据库对应设置 以sae为例

CI application config 文件夹中 database.php文件

switch (ENVIRONMENT)
{
case \'development\':
$db[\'default\'] = array(
\'dsn\' => \'\',

/**** localhost ***/
\'port\' => \'3306\',
\'hostname\' => \'127.0.0.1\',
\'username\' => \'root\',
\'password\' => \'root\',
\'database\' => \'ci\',
/**************************/
\'dbdriver\' => \'mysqli\',
\'dbprefix\' => \'\',
\'pconnect\' => FALSE,
\'db_debug\' => (ENVIRONMENT !== \'production\'),
\'cache_on\' => FALSE,
\'cachedir\' => \'\',
\'char_set\' => \'utf8\',
\'dbcollat\' => \'utf8_general_ci\',
\'swap_pre\' => \'\',
\'encrypt\' => FALSE,
\'compress\' => FALSE,
\'stricton\' => FALSE,
\'failover\' => array(),
\'save_queries\' => TRUE
);
break;
default:

$db[\'default\'] = array(
\'dsn\' => \'\',
/**** sae配置 ***/
\'hostname\' => SAE_MYSQL_HOST_M,
\'port\' => SAE_MYSQL_PORT,
\'username\' => SAE_MYSQL_USER,
\'password\' => SAE_MYSQL_PASS,
\'database\' => SAE_MYSQL_DB,
/*************************/

\'dbdriver\' => \'mysqli\',
\'dbprefix\' => \'\',
\'pconnect\' => FALSE,
\'db_debug\' => (ENVIRONMENT !== \'production\'),
\'cache_on\' => FALSE,
\'cachedir\' => \'\',
\'char_set\' => \'utf8\',
\'dbcollat\' => \'utf8_general_ci\',
\'swap_pre\' => \'\',
\'encrypt\' => FALSE,
\'compress\' => FALSE,
\'stricton\' => FALSE,
\'failover\' => array(),
\'save_queries\' => TRUE
);
}