使用CodeIgniter网站的多服务器环境的解决方案 [英] Solution to multi server environment with a CodeIgniter website
问题描述
我有一个本地,临时和生产环境为我的基于CodeIgniter的网站。越来越多的,我发现每次我部署一个版本,我有越来越多的一点点的代码更改,因为服务器的变化。
I have a local, staging and production environment for my CodeIgniter based site. Increasingly I find everytime I deploy a version I have more and more little bits of code to change because of server variations.
什么将是一个好的可以添加,这将允许我通过只使用一个设置设置这些变量。
What would be a good (and quick) solution I could add that would allow me to set these variables by just using one setting. Where would be the best place to insert this in the index.php, some sort of hook?
推荐答案
定义一个LIVE常数,根据当前域的值为TRUE或FALSE(将其放在index.php文件中)
define a "LIVE" constant which is TRUE or FALSE based on the current domain its on (put this in your index.php file)
if(strpos($_SERVER['HTTP_HOST'], 'mylivesite.com'))
{
define('LIVE', TRUE);
}
else
{
define('LIVE', FALSE);
}
,然后检查您是否存在并分配变量
and then check to see if you are live or not and assign the variables accordingly
if(LIVE)
{
$active_group = "production";
}
else
{
$active_group = "test";
}
我们在过去一年的5个环境设置中没有问题
ive been doing this with our 5 environment setup for the past year with no problems
这篇关于使用CodeIgniter网站的多服务器环境的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!