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 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.
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:
Find the following lines:
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => '', 'password' => '', 'database' => '', );
Also, you need to edit the following file:
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
Edit the following lines to match your needs:
<VirtualHost *:80> ServerAdmin [email protected] 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://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.