April 18, 2012

How to setup CodeIgniter on Ubuntu

Question by user225269

I’m having trouble making my CodeIgniter project work in Ubuntu since I’ve developed it on Windows. My main problem is that I don’t even see any error or warning that can help me determine what the problem is. As you can see it’s just a blank screen. The environment that I’ve declared in the index.php file is development and I’ve also enabled display_errors by setting it to On.

enter image description here

PHP also seems to be working fine since calling php_info() displays something. I believe I’ve also configured mysql properly. I’ve also declared the defaults(host, user, password, port) in php.ini. Can you give me any ideas on how to make something show up?Or something that would allow me to check if I’ve configured things properly. Please help. Thanks!

Answer by user225269

If you’re like me and you have installed Apache, PHP, and MySQL separately using sudo apt-get
then you most likely encounter the same error wherein there is nothing showing up in the logs and on the browser even if you have already set display_errors to on.
What I did was to disable the autoloaded libraries one by one starting from the left.
And my problem was on the database class. Turns out that mysqli and mysql drivers for php isn’t automatically installed when you install php.
All you have to do is to enter the following command:

sudo apt-get install php5-mysql

Doesn’t matter if you have already installed php.

A little help from CodeIgniter could have save me a few hours trying to debug it.

Answer by Starx

The main problem shifting from Windows to Linux development is the naming. Linux distributions are strictly case sensitive regarding almost everything, unlike windows which allows the file indexing, regardless of the case.

First of all to show up something. On the first line of the document index.php

die("Showing Something");

If the message is being displayed, then remove the previous line and add a snippet to show up the errors

error_reporting(E_ALL);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!