CI框架apache相关设置开发模式生产模式自动判断
本地测试环境中
佛山网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联建站公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站。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
);
}
当前标题:CI框架apache相关设置开发模式生产模式自动判断
文章位置:http://hbruida.cn/article/chscsc.html