How to install CodeIgniter on Linux

How to install CodeIgniter on Linux

Today we are going to show you how to install CodeIgniter on Linux.. CodeIgniter is a very powerful PHP web application framework which allows developers to create full-featured web applications with ease. It is a framework with a small footprint, has a clear documentation and uses the Model-View-Controller approach to separate the presentation from logic. Installing CodeIgnitier on your Linux server is an easy task, and it shouldn’t take more then 10 minutes to finish the installation.

Before we start, please take a look at the basic system requirements. CodeIgniter requires PHP version 5.4 or newer and MySQL 5.1 or newer with mysqli and pdo drivers so make sure that your system meets CodeIgniter system requirements.

installing CodeIgniter on Linux

1.  Update the System

 

For this tutorial, we are using an Ubuntu VPS with Ubuntu 14.04 installed. First thing we need to do is to connect to the Linux VPS via SSH and update the system software to the latest version. To update your system software, you can execute the following commands:

apt-get update
apt-get upgrade

2. Download CodeIgntier

The next thing you need to do is to navigate to your server’s directory root and download the current version of CodeIgniter.

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

3. Unzip the archive and set up directory ownership

Unzip the archive you have downloaded using the command:

unzip 3.0.1.zip

Rename the directory to be more user-friendly:

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

3. Edit Apache virtual host file

Now 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>

4. Restart Apache web server

Save and close the file once you are done. Then restart Apache by executing the command below:

service apache2 restart

5. Create new database

Now, create a MySQL database for CodeIgniter:

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

Once you create the MySQL database you need to change the database connectivity settings to the settings needed to access your newly created database.

6. Configure database config file

Edit the following file:

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

Find the following lines:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

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

Here, you need to enter your database connectivity settings. Save the file and close it.

Also, you need to edit the following file:

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

and find the following line to set your base URL:

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

Once you enter your domain name, save the file and close it.

7. Access CodeIgniter via web browser

Next thing you need to do is to open your web browser, enter your domain name in the search field and you will be able to access your CodeIgniter installation.
Use their user guide to find further instructions about how to use this PHP web application framework.


install CodeIgniter on LinuxOf course, you don’t have to install CodeIgniter on Linux, if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install CodeIgniter for you. They are available 24×7 and will take care of your request for installing CodeIgniter on Linux, immediately.

PS. If you liked this post, on how to install CodeIgniter on Linux,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Also, feel free to check out our Codeigniter hosting plans. Thanks.

2 thoughts on “How to install CodeIgniter on Linux”

  1. Hi,
    I really enjoy the tutorials especially the ones on CodeIgniter. Are there more such tutorials? If there are, how can I access them The author of this one is apparently the best I have found in this category. Thanks for the reply and insight.

    Regards,

    Reply

Leave a Comment