config.php for development- and live servers
Posted: Tue Nov 18, 2008 2:21 pm
In most cases of development with CMSms, the development takes place on a development server during a stable version runs on the live server. To transfer the whole project from the development- to the live server, you need to change the config.php every time. I did some changes on the config.php to use it in the same version on both, development- and live server.
At the first step I changed the database vars.
Here I use both database connections. In addition I use the var $config['dev'], to distinguish later on in modules, for example for log files, etc.
Within the next step I get the root url and the root path automatically.
The last step is to change all fixed pathes to dynamical pathes, for example:
Find the complete config.php attached.
What do you think, is there anything wrong with that?
At the first step I changed the database vars.
Code: Select all
$config['dbms'] = 'mysqli';
if ($_SERVER["SERVER_NAME"]=="LocalHostName" || $_SERVER["SERVER_NAME"]=="www.LocalHostName") {
$config['db_hostname'] = 'LocalHostName';
$config['db_username'] = 'LocalUserName';
$config['db_password'] = 'LocalPassword';
$config['db_name'] = 'LocalDBName';
$config['dev'] = true;
} else {
$config['db_hostname'] = 'RemoteHostName';
$config['db_username'] = 'RemoteUserName';
$config['db_password'] = 'RemotePassword';
$config['db_name'] = 'RemoteDBName';
$config['dev'] = false;
}
Within the next step I get the root url and the root path automatically.
Code: Select all
$config['root_url'] = "http://".$_SERVER["SERVER_NAME"];
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
$config['root_url'] = str_replace('http','https',$config['root_url']);
}
$config['root_path'] = $_SERVER["DOCUMENT_ROOT"];
The last step is to change all fixed pathes to dynamical pathes, for example:
Code: Select all
$config['previews_path'] = $config['root_path']."/tmp/cache";
Find the complete config.php attached.
What do you think, is there anything wrong with that?