How To Install CodeIgniter on Ubuntu 14.04

Install CodeIgniter on Ubuntu 14.04

In this tutorial, we will show you how to install and configuration of CodeIgniter on your Ubuntu 14.04. For those of you who didn’t know, CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step-by-step installation of CodeIgniter on the Ubuntu 14.04 server.

Install CodeIgniter on Ubuntu 14.04

Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install LAMP server.

A Ubuntu 14.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here.

Step 3. Install CodeIgniter.

Download the latest stable version of CodeIgniter, At the moment of writing this article it is version 3.0.1:

cd /var/www/
wget https://github.com/bcit-ci/CodeIgniter/archive/3.0.1.zip
unzip 3.0.1.zip
mv /var/www/CodeIgniter-3.0.1 /var/www/codeigniter

Change the ownership of that directory and files:

chown -R www-data: /var/www/codeigniter

Step 4. Configure MySQL Database for CodeIgniter.

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL.

mysql_secure_installation

Next, we will need to log in to the MySQL console and create a database for CodeIgniter. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MySQL root password and hit Enter. Once you are logged in to your database server you need to create a database for the CodeIgniter software:

mysql> CREATE DATABASE codeigniter_db;
mysql> GRANT ALL PRIVILEGES on codeigniter_db.* to 'codeigniter_user'@'localhost' identified by 'YoUrPaS$w0rD';
mysql> FLUSH PRIVILEGES;
mysql> exit

Next, you need to change the database connectivity settings to the settings needed to access your newly created database:

nano /var/www/codeigniter/application/config/database.php

Find the following lines:

$db['default'] = array(
        'dsn'   => '',
        'hostname' => 'localhost',
        'username' => '',
        'password' => '',
        'database' => '',
);

Also, you need to edit the following file:

nano /var/www/codeigniter/application/config/config.php

Find the following line to set your base URL:

$config['base_url'] = 'http://yourdomain.com';

Save the file and close it.

Step 5. Configure Apache2 web server.

Edit the virtual host file and change the document root to point to /var/www/codeigniter:

nano /etc/apache2/sites-enabled/000-default

Edit the following lines to match your needs:

<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/codeigniter/
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<Directory /var/www/codeigniter/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/yourdomain.com-error_log
CustomLog /var/log/httpd/yourdomain.com-access_log common
</VirtualHost>

Save and close the file once you are done. Restart the Apache service for the changes to take effect:

service apache2 restart

Step 6. Access CodeIgniter.

CodeIgniter will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com or http://server-ip-address and complete the required steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulations! You have successfully installed CodeIgniter. Thanks for using this tutorial for installing CodeIgniter on Ubuntu 14.04 system. For additional help or useful information, we recommend you to check the official CodeIgniter website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save