Ubuntu – Unable to load dynamic library ‘/usr/lib/php5/20090626+lfs/sqlite.so’

The other day, I was getting this weird error

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Fix it by doing this

root@beta:~# rm -fr /etc/php5/conf.d/sqlite.ini

Because this extension does not exist, you can verify it by running this, you will see that there is already sqlite3.ini file there

root@beta:~# ls -lh /usr/lib/php5/20090626+lfs/ | grep sqlite

Just released – PHP SolusVM Wrapper class

I have just released a SolusVM wrapper class based around the SolusVM Client API. More details on the project homepage new project homepage on GitHub. You can also download the complete code from GitHub, fork it on GitHub to improve it and/or watch/start it

Update Nov 29, 2012: Moved from Google Code to GitHub because GitHub is a graet place for open-source stuff. Google Code is so old school now

Using Facebook Graph API to keep an eye on friends activity

Life is really moving in the fast lane for me, and Im pretty sure for most of you readers too. I login to social-networking platforms after weeks and I cant recognize most of these faces (even though they are my friends). Its proven that Humans tend to recognize people by face more quickly then names and email addresses so whenever someone puts on a new face (uploads a new profile-picture), I have hard time getting to know them.

Well, I thought today, I have been developing in facebook application for so long now – Why not put online a few hours to fetch Facebook Friends data via API and keeping track of who did what? (status updates) and who changed his/her profile picture? So last night I was up, as usual, and I put together a small script in PHP that fetches my friends’s list, processes newcomers, checks for updates (pictures and statuses) and posts them into a database. Now I can track who updated his profile picture and what was their previous profile photo. Also, I can invest in another 1 hr to create high-level-summary everyday for ME 🙂

Do you do something of this sort? I’d love to hear your story

Installing Lighttpd, PHP and MySQL on Ubuntu

If you are not getting a package on Ubuntu, please check to see if your /etc/apt/sources.list file is updated. This is common with most VPS providers

On VPS, especially with challenging small memory limit (e.g. 64MB or 128MB) lighttpd is the best option instead of Apache. In this article I will show you how to do that. On a fresh box (which has no apache installed) type this to get lighttpd webserver installed

apt-get install lighttpd

Now install PHP5 CGI package and PHP5 command line package

apt-get install php5-cgi php5-cli

Edit the following file

nano /etc/php5/cgi/php.ini

and uncomment this line

cgi.fix_pathinfo = 1

Now enable fastcgi module

lighty-enable-mod fastcgi

Restart Lighttpd

/etc/init.d/lighttpd restart

You get the welcome page

Lets install MySQL 5.1 server and client

apt-get install mysql-server mysql-client

and optionally phpMyAdmin

apt-get install phpmyadmin

Now create a test page to see if phpinfo is all Ok

nano /var/www/info.php

Type in the following


Installing PHP’s SSH2 extension on Ubuntu

On Ubuntu 10.04 LTS, Do this (there’s no need to do any compiling anymore)

apt-get install libssh2-1-dev libssh2-php

You can now test if PHP recognizes it’s new ssh2 extension by running:

php -m |grep ssh2

Don’t forget to restart Apache

service apache2 restart

Good bye CentOS! Hello Ubuntu

Its been about almost more then two years since I have been playing with CentOS on many different platforms etc. Its very stable but on the other hand, PHP/MySQL updates are very hard to get and still PHP is 5.1.6. I tried EPEL repo and it updated PHP to 5.3.1 but still there were conflicts with stuff and many core packages.

So, I thought why not move to Ubuntu since it has just announced 10.04LTS (Long Term Support) in April 2010. Folks at iWeb were really nice to do a reinstall without any charges and also process a memory upgrade request at an amazing 50% discount.

Ubuntu 10.04 LTS

  • Apache 2 version is 2.2.14
  • PHP version is 5.3.2
  • MySQL version is 5.1.41-3ubuntu12
  • SVN (Subversion) version is 1.6.6

As a comparison CentOS 5.4 has the following versions

  • Apache 2 version is 2.2.3
  • PHP version is 5.1.6
  • MySQL version is 5.0.77
  • SVN (Subversion) version is 1.4.2

So if you are a PHP developer looking to deploy a Linux flavour on your new box, choose Ubuntu 🙂

Kohana or CodeIgniter or CakePHP?

I am going to start on a small system for internal use and I wanted to re-think my choice of CodeIgniter because it does not have templates or ORM. Guess what, I landed with KohanaPHP. It sounds very tempting that a new MVC Framework based on CodeIgniter with new features (especially ORM) is here but the documentation is really really poor.

I tried googling for a book or tutorial and I was really disappointed to have found none. I tried Amazon.com for a book but no books. Looks like I have landed in some weird space that might be good looking but I need to get my hands dirty in the code to learn it and at the end of the day, it may seem that I have lost a lot of hours on this new Framework. Lets give it a try!

Update: As of today (28th July, 2010), I am working on YII, its good, powerful and blazing fast. It has all the feature of CakePHP too.

Creating and Installing crontabs using CodeIgniter

Last night, I was trying to get a crontab working in CodeIgniter, since my current project (a personal project) is using CodeIgniter now. I didn’t wanted to use the conventional approach of running crontabs and my code seperate.

Unfortunately, CodeIgniter does not have support for Crontabs and I didn’t wanted to user wget in linux crontab to initiate unwanted requests.

I spent some time and came up with a solution. It uses

  1. CodeIgniter backend
  2. Does not modify any core architecture of CodeIgniter
  3. Keeps configuration at one place

So enough of the summary and let me show you how its done.
Create a file (e.g. cron.php) in the same place as your index.php and system folder. Here is its code

* @author 	    Asim Zeeshan
* @web         http://www.asim.pk/
* @date		13th May, 2009
* @copyright 	No Copyrights, but please link back in any way

$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];

if ($argc > 1 && isset($argv[1])) {
$_SERVER['PATH_INFO'] 	= $argv[1];
$_SERVER['REQUEST_URI'] = $argv[1];
} else {
$_SERVER['PATH_INFO'] 	= '/crons/index';
$_SERVER['REQUEST_URI'] = '/crons/index';

| PHP SCRIPT EXECUTION TIME ('0' means Unlimited)


/* End of file test.php */

Now, we need a controller e.g. test so the controller code could be something like this. Please note that normally we do not need to output anything from these controllers since they are doing some background work or sending emails but for the sake of giving an example, I will be output-ing something to elaborate the example.

* @author 	    Asim Zeeshan
* @web         http://www.asim.pk/
* @date		13th May, 2009
* @copyright 	No Copyrights, but please link back in any way

class Test extends Controller {

function __construct()

function index()
echo "testing from index \n";

function test() {
echo "testing from test \n";

Now execute crontab on linux command prompt

php /full-path-to-cron-file/cron.php /test/index

Voila! all you need now, is to setup the crontab like you normally do.
This code is not shared under any license so feel free to copy/modify/use it. Please link back to this website / post in any way e.g. direct link, credits etc.

P.S. The examples above user PHP5 constructor, If you need to execute this code on PHP4, please modify the constructors.

Template Library for CodeIgniter, Simple, Fast and Easy!

If you have not noticed, I just got started on CodeIgniter. I was really disappointed today when I noticed the lack of a template system in CodeIngiter to skin my little application. They say

The Template Parser Class is not a full-blown template parsing solution. We’ve kept it very lean on purpose in order to maintain maximum performance.

Lucky for me, I got a little help here, the library is great and works well for the latest version of CI too best of all its small and does not modify the CI code in anyway. It just uses the already available code to skin the application. Sleak!

I made a couple of modifications in the original library, here are my modifications

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Template {
	var $template_data = array();
	function set($name, $value) {
		$this->template_data[$name] = $value;
	function load($template = '', $view = '' , $view_data = array(), $return = FALSE) {
		$this->CI =& get_instance();
		$this->set('contents', $this->CI->load->view($view, $view_data, TRUE));			
		return $this->CI->load->view($template, $this->template_data, $return);
	// load a default template 'template.php'
	function view($view = '' , $view_data = array(), $return = FALSE) {
		$this->CI =& get_instance();
		$this->set('contents', $this->CI->load->view($view, $view_data, TRUE));			
		return $this->CI->load->view('template', $this->template_data, $return);

/* End of file Template.php */
/* Location: ./system/application/libraries/Template.php */

So now I use it like

$this->template->view('my_view', $view_data);

instead of

$this->template->load('template', 'my_view', $view_data);

Hope it helps somebody.