[eluser]Daniel Moore[/eluser]
I generally, when hosting multiple sites on a shared server setup, will do something like the following:
Code:
[system]
[accounts]
--[client1name]
--this_domain.php
--[application]
--[html]
--index.php
--[client2name]
--this_domain.php
--[application]
--[html]
--index.php
I have a universal index.php that I do not have to change across accounts, because I can point to the same absolute system directory, and the application directory is always '../application'. I just do a "require_once('../this_domain.php');" at the beginning of the index.php. This also prevents me from having to touch config.php in "application/config" because I preset it to have the following:
$config['base_url'] = "http://".THIS_DOMAIN_NAME."/";
The constant THIS_DOMAIN_NAME is defined in the 'this_domain.php' file.
The advantage of this is I use an if-statement to check if I am running the app on my local development machine (XAMPP) or if it is on the live server. If on my local development machine, then it uses THIS_DOMAIN_ALIAS for the base_url. This way I don't have keep a separate configuration file for local and live, it just works.
this_domain.php includes the following:
Code:
if ($_SERVER['SERVER_NAME'] == 'host_I_defined_in_apache_config') // usually 'localhost'
{
define('THIS_DOMAIN_NAME', 'host_I_defined_in_apache_config/example.com');
define('MY_DB_USER', 'local_dbusername');
define('MY_DB_PASSWORD', 'local_dbpassword');
define('MY_DB_HOST', 'local_dbhostname');
define('MY_DB_NAME', 'local_dbname');
}
else
{
define('THIS_DOMAIN_NAME', 'www.example.com');
define('MY_DB_USER', 'live_dbusername');
define('MY_DB_PASSWORD', 'live_dbpassword');
define('MY_DB_HOST', 'live_dbhostname');
define('MY_DB_NAME', 'live_dbname');
}
As you can see, that also allows me to set up my database configuration so that I don't have to touch it either. That way, when I set up a new site, I just fill in the blanks (so to speak) in this one file and get started. It makes it much easier for me to migrate from local development machine to a live server, since I don't have to change settings back and forth.
It may not be the best practice, but I prefer to have only one version of all the files, and I don't want to maintain a separate copy for local development and live, even if it is just one or two files.