
To configure your install to support multiple sites, not only do you make the updating of the cogeigniter core easier, but also make the codeigniter install more secure as a whole.
In this tutorial, I’m setting up my multiple codeigniter sites on my local XAMPP install, which is on my M:\ drive. Your Apache setup may be different, so do take note of my settings and adjust according to your own web server environment.
I’m planning to setup two sites just for illustration – http://dev.ci/ and http://live.ci/.
Codeigniter default folder structure
After unzipping the default codeigniter files, you would get something like this:

You would have set your Apache’s configuration to point to your CI folder (which is M:\xampplite\CodeIgniter_1.7.1 for me) as the document root. Once you run the site in the browser, you would get the default welcome page of codeigniter.
If you have setup the default CI before, you may know that within the system folder are a many core folders which you don’t normally need to touch and the application folder which will house all your codes for your site. You may also have noticed the index.php file in the root of the codeigniter directory, which you didn’t really need to touch before but will become crucial in setting up multiple sites.
Adjusting the application folders
First thing to do is to move the application folder out of the system folder to the same level as the system folder.

Since I’m setting up to run two distinct sites sharing the same CI core, I will make another copy of the application folder and rename both folders to reflect the different sites.
Create the web root folders
Now we need two folders which will be the website’s root folders. This is how I setup mine

Make copies of the index.php file located in the codeigniter root folder (ie M:\xampplite\CodeIgniter_1.7.1) into each of the htdocs folder. In this case, I would have one index.php in each of my htdocs_ci_dev and htdocs_ci_live folders.
Open index.php file for each site and edit the following lines.
At Line 26: $system_folder = "system"; Change to $system_folder = "../system"; At Line 43: $application_folder = "application"; Change to $application_folder = "../app_ci_dev"; (for the htdocs_ci_dev) or $application_folder = "../app_ci_live"; (for the htdocs_ci_live)
Configure Apache virtual hosts
Once that’s done, the last thing to do is to setup the Apache virtual host configuration of my XAMPP install.
My Apache virtual host configuration looks like this:

Don’t forget to edit your local hosts file so that your system recognizes the dev.ci and live.ci domains.
Once you fire up your Apache web server, you should be able to load either site accordingly (*fingers crossed*)
Renaming the system folder
If you want to go further you can rename the system folder to reflect the different CI versions. This way, when a new version of the CI core is released, you can configure your sites easily by just changing $system_folder parameter in the index.php file (Line 26) for each site.

Conclusion
If you like this setup, you can easily expand the codeigniter install to more sites. There is also no doubt that this is more secure than the default codeigniter setup, as the only folders which are exposed to the browser are the htdocs folders – all the application and system folders are no longer accessible through the web server.
Related posts:
- Important Website Security Tips Website Security is a very important subject and always needs...
- Memcached Server Installation and Access with PHP An exclusive tutorial about MEMCACHED Server, its simple installation method...
- Image Magick and GD library installation on FEDORA server If you are dealing with the images in PHP then...
- CodeIgniter – Change the name of your methods in a url Codeigniter framework has a built in method named _remap which...
- How To Secure WordPress Blog There are various reasons that why it is important to...
Related posts brought to you by Yet Another Related Posts Plugin.






















5 Responses
[...] Read more: Setting Multiple Websites in Codeigniter Installation – An … [...]
Good post and this enter helped me alot in my college assignement. Say thank you you as your information.
[...] and you will see the ci_series_1 well come message. You can see related article in exclusivetutorials [...]
[...] Setting Multiple Websites in Codeigniter Installation Sharevar fbShare = {url: 'http://bloglinks.ejazahmad.com/setting-multiple-websites-in-codeigniter-installation/',size: 'large',}Save submit_url = 'http://bloglinks.ejazahmad.com/setting-multiple-websites-in-codeigniter-installation/'; VN:F [1.9.1_1087]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.1_1087]Rating: 0 (from 0 votes) Directory, PHP, Tutorials [...]
what was in the htdocs_* folder and what is the content of the app_ci_* folder?
whether the contents of both are different?