CodeIgniter is a PHP framework used to build a web application that is widely used by developers worldwide. Before you install CodeIgniter, make sure the following are installed beforehand –
- Webserver Apache or Nginx
- PHP 5.6
- MySQL
- Composer
Once you confirm that the above-listed components are in your server, proceed to install CodeIgniter with the following steps.
1. Set SELinux status to disable.
# SELINUX=disabled
2. Let us create MySQL Database for CodeIgniter.
# create database mycode_db;
grant all privileges on mycodeusr.* to mycode_db@'localhost' identified by 'your_password';
flush privileges;
exit
3. Now, we will install Composer Package Manager.
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer
exit
4. We will install CodeIgniter.
Go to the root directory HTML.
# cd /var/www/html/
5. Clone CodeIgniter from its git repository.
# git clone https://github.com/bcit-ci/CodeIgniter.git
6. We will install the required dependencies running composer.
# composer install
7. Provide file ownership of files to the Apache user.
# chown -R apache:apache /var/www/html/
8. We will configure the base URL by editing the config.php file.
# vi /var/www/html/application/config/config.php
9. Locate the below line.
$config['base_url'] = '';
10. Modify this line by adding your application URL in the quotes.
$config['base_url'] = 'http://192.168.2.152';
11. To configure the CodeIgniter Database connection setting, edit the following file with your preferred text editor –
# vi /var/www/html/application/config/database.php
12. Locate the path given below –
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'mysqli',
Change it to –
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'mycode_db',
'password' => 'your-db-user-password',
'database' => 'mycodeusr',
'dbdriver' => 'mysqli',
13. Once you are done with the changes, save this file.
Access the URL you added earlier in base_url and verify that CodeIgniter is working.