Click Technology

Linux, Windows, Mac it's all good

Set up CodeIgniter quickly…


The CodeIgniter framework is great, even the documentation is spot on being short and to-the-point.

They have installation instructions, sure, but here’s the commands to download it and set it up with the folders in the correct place.

First step, log into your server over SSH. I assume you are using Apache in this process for the web configuration, and that your root folder for serving web files is /var/www as is typical.

If you’re using nginx or something else, server side config is still straightforward, just a question of setting your document root AFAICS.

Here’s the steps..

This will download the CodeIgniter yip, unpack it, set it up, add a .htaccess file, set up the database connection and make you feel good about yourself generally. Use with the ususal care and attention.

cd /var/www
sudo rm -rf /var/www/
sudo mkdir /var/www/
cd /var/www/
sudo wget --output-document=./
sudo unzip
sudo rm
sudo mv ./CodeIgniter_2.2.0 ./public_html
sudo mv ./public_html/system/ ./
sudo mv ./public_html/application ./
sudo sed -i s/"$system_path = 'system';"/" = '\/var\/www\/\/system';"/g ./public_html/index.php
sudo sed -i s/"$system_path = 'application';"/" = '\/var\/www\/\/application';"/g ./public_html/index.php
sudo su -c $'echo "RewriteEngine on" >> /var/www/'
sudo su -c $'echo "RewriteCond \$1 !^(index\.php|images|robots\.txt)" >> /var/www/'
sudo su -c $'echo "RewriteRule ^(.*)$ /index.php/\$1 [L]" >> /var/www/'
sudo sed -i s/"\$autoload\['libraries'\] = array('');"/"\$autoload\['libraries'\] = array('database');"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['username'\] = '';"/"\$db\['default'\]\['username'\] = 'your_database_username_for_your_codeigniter_app';"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['password'\] = '';"/"\$db\['default'\]\['password'\] = 'your_database_password_for_username_above';"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['database'\] = '';"/"\$db\['default'\]\['database'\] = 'my_codeigniter_app_database';"/g /var/www/
sudo su -c $'chown -R www-data:www-data /var/www/'
sudo su -c $'find /var/www/ -type f -print0 | xargs -0 chmod 0664'
sudo su -c $'find /var/www/ -type d -print0 | xargs -0 chmod 0775'
sudo su -c $'service apache2 restart'

OK, that’s it. Start working on the app. The part below was a step by step for the apache side of things when I wrote the article earlier, so I’ll leave it here for inspection. As far as you’re concerned, the CodeIgniter app is ready to go.

All you need to do now is configure your apache server. You’re using virtual hosts? Great. here’s the code..

Create the site configuration file…

sudo touch /etc/apache2/sites-available/

Open it for editing (say with vim or your favourite editor)

sudo vim /etc/apache2/sites-available/

Paste in the code below…

<virtualhost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/
                Options FollowSymLinks
                AllowOverride None
        <directory /var/www></directory>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

Save and close the file with


Now create a symlink from the sites-available to the sites-enabled folder to make the site appear…

sudo ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

.. and restart apache..

sudo service apache2 restart


posted under Linux Tips | No Comments »

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.