Home Archive RSS Login

I learned something new today

Install MongoDB, Xdebug and PHP 5.3.3 on Ubuntu 9.10

Here is a nice video that shows you how to install PHP 5.3.*, Xdebug, MongoDB and getting started with Lithium, the most RAD framework for PHP 5.3+.

I will note down some of the steps here anyway on how I did on Ubuntu. I started from Ubuntu Server installation and hence already had Apache on the system. Hence, some steps might be different.
sudo apt-get install apache2-prefork-dev

Now the web server must be running at http://localhost. The document root that is setup by default on Ubuntu is /var/www. 

1. PHP 5.3.3

Now head over to the php website and grab the PHP 5.3.* source. At the time of writing this post, it was 5.3.3. Here is the command line I used:
cd ~
wget http://www.php.net/get/php-5.3.3.tar.gz/from/us.php.net/mirror
tar -xzvf php-5.3.3.tar.gz
cd php-5.3.3

You can create a config.clean script in this directory and add the lines shown.
nano config.clean
and paste the following lines:
#! /bin/sh
# ..-. .- .. .-..  ..-. .- ... -
Now you can run the following:

sudo apt-get install libxml2-dev libbz2-dev libcurl4-gnutls-dev libjpeg62-dpg libpng12-dev libxslt1-dev

sudo sh ./config.clean

make -i install

Now PHP 5.3.3 installation is complete. 

2. Xdebug Installation

# install dependancies
sudo apt-get install php5-dev

#install xdebug
sudo pecl install xdebug

# copy and start editing php.ini to add xdebug module
sudo cp /etc/php5/apache2/php.ini /etc/php5
sudo nano /etc/php5.ini 
# Add the following to the end:

3. MongoDB Installation

sudo mkdir -p /data/db

# Download Mongo
curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.4.tgz > mongo.tgz
tar xzf mongo.tgz

# start mongod server

# start mongo client 

Now you can try out mongodb by referring to the documentation on their website at http://mongodb.org
Author: Prit -  Date: 27 Jul 2010 18:36
Tags: mongodb,php -  Visits: 8482 -  No Comments

Load a PHP extension at runtime

Recently my hosting company did some upgrade to PHP and it messed up my Pritlog sites because they were using Sqlite. I had a chat with them and they could fix the issue. Later I realized that they only fixed the issue when the PHP application was running from the web. If it was from the command line (CLI), then this issue would still be there. Upon contacting them again, they were taking a lot of time to figure out the problem and fix it. This is when I started searching for an alternative solution to this problem.
I came across this PHP function called - "dl". Using this, you can dynamically load the required extension (provided it is available on your server) during runtime. You can refer to the page on the PHP website that talks about this function.
Here is a simple code that can be used to load the sqlite extension.
// Example loading an extension based on OS
if (!extension_loaded('sqlite')) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    } else {
When I plugged this code into my script, it started running fine.

Author: Prit -  Date: 18 May 2009 17:34
Tags: programming,php -  Visits: 57169 -  No Comments

Pages: [1]