How to set up configuration file for multiple servers
If you install Joomla on multiple servers, you can have a config file that works on all servers. You don’t have to change the config file everytime you copy to a different host. I will show you how to do it easily, so you can work on a development server as well as production server without breaking the site.
Open the config file in Joomla root folder. You can use Notepad or any PHP Editor. Add a condition statement “if else” right before the class JConfig.
$server = $_SERVER[‘HTTP_HOST’];
if($server == ‘server1’){
//place the class Config here and change all appropriate variables for that server
class JConfig {
var $offline = ‘0’;
var $editor = ‘tinymce’;
…
var $host = ‘host_1’;
var $user = ‘username_1’;
var $db = ‘database_1’;
var $dbprefix = ‘js_’;
} //remember to close your class
}
else{
//place the class Config here and change all appropriate variables for the second server
class JConfig {
var $offline = ‘0’;
var $editor = ‘tinymce’;
…
var $host = ‘host_2’;
var $user = ‘username_2’;
var $db = ‘database_2’;
var $dbprefix = ‘js_’;
} //remember to close your class
}
You’re done! Now you can use the file on 2 different servers. If you have more than 2 servers, use another if or you can start using switch() function.