Getting Started With CodeIgniter – 1

Installing CodeIgniter – a PHP Framework – On Your PC

First, be aware, I am not a CodeIgniter expert. I am a relatively new user and am just trying to find my way around it.  This series of posts is to give you a blow by blow account of how I am putting a CodeIgniter web site together, in real-ish time. If I succeed it will mean anyone can do this.

If you are new to PHP and want to get a head start, but think a framework is just too difficult, I am going to attempt to get you started. (Famous last words).  For a real CodeIgniter experts visit the CI forums.

CodeIgniter has to be the easiest PHP framework to install.  This is why it is my framework of choice. I am going to explain how to set it up locally to run on a PC. Before you start you are going to need the following:

  • PHP installed on your local computer and on your web server (PHP 4.3.2 at least), and a database, (MySQL 4.1 at least). There is more information in the user guide about support for other databases.
  • A PHP/HTML editor. I either WeBuilder. There are other arguably better development environments, but I lose patience with the difficulty to install them, and the mass of software to install to make the run in debug mode. This means I tend to debug in my head and with various output statements. Stone Age I know, but it hasn’t caused me any problems so far.
  • A root directory where your local web server expects to find sites you run locally.

My local web server root directory is : C:\Users\Lizzy\Documents\websites and this is where my local installation of Apache has its root directory set.
Code Igniter Directory Structure

  1. Download the latest version of CodeIgniter from the CodeIgniter Web Site. At the time of writing this was version 1.7.0
  2. Decide on a name for the new web site you are about to create using CodeIgniter. In my example this will be chaingang3, but obviously you will choose your own, and substitute that where I have chaingang3.
  3. Unzip the entire contents of the CodeIgniter zip file into local root directory (as specified in your httpd.conf file if you are running Apache). For example in my httpd.conf file, DocumentRoot is “C:\Users\liz\Documents\Websites” so I unzipped the CodeIgniter installation to that location.
  4. Once unzipped, rename the CodeIgniter_1.7.0 directory to the name of your web site. In my case I renamed it to chaingang3.
  5. You’ll end up with a directory structure looking like the image on the right within your root directory, wherever yours is.
  6. Next you have to configure CodeIgniter. This is easy to do. Open up the config directory that you can see within the application directory and open the file called config.php

Changes to Config.php

config.php locationThe only changes you need to make to this file (to begin with) are are shown here in the Base Site URL section. You’ll find config.php in the directory as shown by the pink arrow on the right.

You just specify the starting position of the site on your local machine, and also on its ultimate server destination.


Note that I put two base_url values and some code to decide which is applicable, either locally or on the web server.

OK – that’s it for now. I have to drive to Exeter to meet my husband on the train.

Next post will be getting the CSS and other supporting directories in, the database and getting the system to run.

if($_SERVER['HTTP_HOST'] == "localhost"){


  1. [...] the software and altered the config.php file by adding two lines (one commented out). Please review Getting Started With CodeIgniter – 1 for [...]

Speak Your Mind


CommentLuv badge