Use CodeIgniter on localhost with Ubuntu Jaunty
Hi,
As a PHP developer it comes in handy to run your websites without having to upload them to your server. You can run them on your own computer if you want to, there isn’t much to it. I also like using the CodeIgniter framework for my projects, this is a really speeds up the whole process!
I will take you through the basic steps to set up your localhost to get CodeIgniter running.
1) Use Synaptic package manager to install “apache2″, “php5″ and “mysql-server”.
During the installation you will be asked to enter the password for the root user for your mysql-server.
2) Create a symbolic link, so that when you go to localhost in your browser, you get the website you want.
sudo cd /var/ sudo rm -r www/ sudo ln -s /path/to/website www
Always look before you delete something with “rm -r”, normally there should only be a index.html file in your www/ folder.
I prefer creating a link to my website that I put somewhere in my home directory, as this is being back-upped frequently, and is on another partition.
3) Install the package “phpmyadmin” through synaptic.
It is important that you wait to install phpmyadmin until you have installed the other packages and created the symbolic link. Otherwise it can be a mess to get things running.
4) To allow mod-rewrite, to get the clean CodeIgniter URL’s, you need to do the following.
sudo a2enmod rewrite sudo nano /etc/apache2/sites-available/default
You will see something like this:
DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
Change the AllowOverride’s to All.
5) Restart Apache
sudo /etc/init.d/apache2 restart
This wasn’t so hard, and it really makes life easier!
Note: You can’t use the function mail() or CodeIgniter’s mail-class without further configuration. I won’t go into details about this.
Also note that there are many ways to tackle this, this is only one easy suggestion. If you need to switch a lot between different websites, then changing the symbolic link each time is too much work. You can check out this article here.
Happy coding!

Works on ubuntu 9.04, just follow the directions. I used sudo ln -s /home/myusername/workspace www to be able to use the workpace I had set up for aptana/eclipse…restart your apache and your url will be http://localhost/myapp/
if /myapp is where you are looking for code igniter or other app
Save me lots of time – thanks.