Setting up CodeIgniter Framework

(Current Version 3.0.6)

CodeIgniter is an web application development framework for building web sites using PHP. It allows much faster development of PHP projects than writing application from zero.

CodeIgniter provides a lot of libraries for various tasks and easy access to them.

Using CodeIgniter makes code writing much simpler and require a lot less coding

To do list:

  1. Downloading CodeIgniter
  2. Installing CodeIgniter
  3. Cleaning up after install
  4. Configuring CodeIgniter

Setting up Codeigniter Framework

1. Downloading CodeIgniter

Go to web directory of your server:

cd /var/www/

Type this to download it:

wget https://github.com/bcit-ci/CodeIgniter/archive/3.0.6.zip

This will download .zip file from official download link

 

2. Installing CodeIgniter

To unzip this archive, you need to have unzip installed.

If you don’t have it, install unzip first:

sudo apt-get install unzip

Now when you have unzip installed, type following command to unzip CodeIgniter archive:

unzip CodeIgniter-3.0.6.zip

This will uncompress archive and you should get CodeIgniter-3.0.6 directory on your server

 

3. Cleaning up after install

Remove compressed archive because you don’t need it anymore.

rm CodeIgniter-3.0.6.zip

Rename CodeIgniter-3.0.6 directory to something easier to remember.

mv CodeIgniter-3.0.6 codeigniter

This will rename directory with new name: codeigniter
You can now access it in your web browser:

http://localhost/codeigniter

You should see CodeIgniter Welcome page which looks like this:

CodeIgniter Welcome Page

4. Configuring CodeIgniter

If you want to use database for your application, you need to edit database.php file to enter variables needed for connection to database.

Go to web root directory if you are not in it:

cd /var/www/

And type:

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

Find DATABASE CONNECTIVITY SETTINGS section and edit like this:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'your_database_username';
$db['default']['password'] = 'your_database_password';
$db['default']['database'] = 'your_database_name';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Save and exit file.

After that you need to edit config.php file.

nano ./codeigniter/application/config/config.php

Set base_url:

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

Save and exit file.


 

You’re done configuring CodeIgniter, it is ready for use.

If you want to remove extension from URL, you should check out our article Configuring .htaccess file for prettier URLs

 

Leave a Reply

Your email address will not be published.