How to install and Configure the CodeIgniter Framework

How to install and Configure the CodeIgniter Framework

Share Now
3 min read
182

There are few steps we need to apply in an order

Note: We are considering the installation of codeigniter on Centos 7.

  • Install LAMP
  • Install PHP5
  • Install DB
  • Configure DB
  • Install phpMyAdmin
  • Install Configure
  • Configure Codeigniter

Update the OS

  1. yum update -y

Install LAMP onCentOS-7

  1. Install Apache with basic config
    1. yum install httpd
  • Use the following commands to manage Apache daemon
    • apachectl configtest| graceful
  • Configure the Firewall
    • Restart the Firewall
      • systemctl restart firewalld
      • firewall-cmd –add-service=http
      • firewall-cmd –permanent –add-service=http
      • firewall-cmd –reload

Note: To allow https, repeat the same step again for sevice https

  • Now, restart the httpd service
    • systemctl restart httpd
  • To check the status
    • systemctl status httpd
  • Now, open browser and type the IP, You will see Apache website

Install PHP5 support for Apache

  1. To get the full available PHP modules, use this command
    1. yum search php
  • For a normal LAMP server, install the below modules
    • yum install php php-mysql php-pdo php-gd php-mbstring

Here,

php-pdo.x86_64 : A database access abstraction module for PHP applications

php-gd.x86_64 : A module for PHP applications for using the gd graphics library

php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

Install and Configure DB[Here we will use MariaDB]

  1. yum install mariadb-server mariadb -y
  1. Start database daemon and use mysql_secure_installation script
    1. systemctl start mariadb
  2. Configure the Maria DB
    1. mysql_secure_installation
  • To test database functionality login to MariaDB using its root account and exit using quit statement.
mysql -u root -p
MariaDB > SHOW VARIABLES;
MariaDB > quit

Install PHP-MyAdmin

  1. Install the required package for the phpMyAdmin
    1. yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
  • Install PhpMyAdmin.
    • yum install phpMyAdmin -y
  • Configure PhpMyAdmin to allow connections from remote hosts by editing phpmyadmin.conf file
    • vi /etc/httpd/conf.d/phpMyAdmin.conf
    • Change 127.0.0.1 to below
  • systemctl restart  httpd
Note: If you don`t do the above configuration right, when you access the phpMyAdmin url, you may get error message like
1.Forbidden You don’t have permission to access /phpmyadmin/on this server Job for httpd.service
2. Failed because the control process exited with error code.If you get any of these error, ensure to check the phpMyAdmin.conf file and look for Require IP and Allow from
I got these as an error message while the configuration was not set correctly and once I made the changes as per the screenshot above, those error were not there anymore.
  • Note: If you want to change the URL from http://IP/phpmyadmin to http://IP/some_other_name
    • vi /etc/httpd/conf.d/phpMyAdmin.conf
    • Comment out the default two Alias lines and write your own alias there.
#Alias /phpMyAdmin /usr/share/phpMyAdmin
#Alias /phpmyadmin /usr/share/phpMyAdmin
Alias /some_other_name /usr/share/phpMyAdmin
Change the name from “some_other_name” to any custom name as per the requirement
  • Restart the httpd service.
    • systemctl restart  httpd

Install Codeigniter on the CentOS LAMP

  1. Disable SELINUX

Check the current status

sestatus

To disable the SeLinux

vi /etc/sysconfig/selinux

Edit with this

SELINUX=disabled

Codeigniter database configuration

mysql -u root -p

create database code_db;

CREATE USER codeignitersuser@localhost IDENTIFIED BY ‘password’;

GRANT ALL PRIVILEGES ON code_db.* TO codeigniteruser@localhost;

FLUSH PRIVILEGES;

Exit

  • Install composer package manager

If you wish to install CodeIgniter dependencies, you will need composer. It is easy to install with the following commands:

curl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer

chmod +x /usr/local/bin/composer

  • Install Codeigniter Frameowrk

cd /var/www/html/

yum install -y git

git clone https://github.com/bcit-ci/CodeIgniter.git  .

Install the required dependencies

composer install

Change the ownership of the root files to the user apache

chown -R apache:apache /var/www/html/

  • Configure Base URL for Codeigniter, by updating the variables

vi /var/www/html/application/config/config.php

Change $config[‘base_url’] = ”; to $config[‘base_url’] = ‘http://IP’;

  • Configure the DB

vi /var/www/html/application/config/database.php

Edit these info

$db[‘default’] = array(         ‘dsn’   => ”,        
‘hostname’ => ‘localhost’,        
‘username’ => ‘code_db’,        
‘password’ => ‘password’,        
‘database’ => ‘code_db’,       
‘dbdriver’ => ‘mysqli’,
This is just an example as per my lab for codeigniter installation.

Leave comment

Your email address will not be published. Required fields are marked with *.