Monday, January 17, 2011

How to install xdebug & MysqlND on CentOS

1. yum install php-pear

2. Yum install php-devel

The pecl command can then be found at /usr/bin/pecl

You can just use the pecl command to install new extensions like

3.sudo pecl install xdebug

Build process completed successfully

Installing '/var/tmp/pear-build-root/install-xdebug-2.1.0//usr/lib/php/modules/'

install ok: channel://

You should add "" to php.ini

At this point, you should open your php.ini file an add the line as suggested, but use the zend_extension directive as follows:

zend_extension = usr/lib/php/modules/

How to Test it

vim xdebug.php

function test(){

echo "Called @ ".xdebug_call_file().

":".xdebug_call_line()." from".





:wq (Save and exit)


# php -e xdebug.php

should return like

Called @ /root/phpscript.php:8 from{main}

wow, you are done....

mysqlnd is a 5.3 feature

MySQLnd will most likely be the database driver for both the PDO MYSQL extension

and mysqli extension in PHP 5.3. It is still under development, but there are

currently releases for the mysqli extension.

The MySQL native driver for PHP is part of the official PHP source code repository at It is contained in the PHP source code as of PHP 5.3.

If you are compiling PHP yourself, please use the configure options

--with-mysql=mysqlnd, --with-mysqli=mysqlnd and --with-pdo-mysql=mysqlnd

to compile PHP with mysqlnd support.

Let’s see how PHP and MySQL works together. Here is the list of three extensions which PHP uses to connect to MySQL.

pdo mysql

All of the above mentioned extensions are rely on MySQL’s client library libmysql. Mysqlnd is an another and alternative way of connecting PHP 5 and PHP 6 to the MySQL Server. Now the question arises why use Mysqlnd instead of other extensions ?

Here is the list of advantages of Mysqlnd library over other mentioned extensions.

  • It is very easy to compile, it does not have any dependencies issues with mysql client programming support.
  • It performs much better then libmysql in certain cases.
  • It provides persistent connections for mysqli.
  • It key feature is that it uses PHP memory management and it supports PHP memory limit.
  • It is famous for reducing memory footprint because it stores every row only once in memory while in the case of libmysql it is saved twice in memory.

By default the MySQL database extensions are configured to use MySQL Client Library. In order to use the MySQL Native Driver, PHP needs to be built specifying that the MySQL database extensions are compiled with MySQL Native Driver support. This is done through configuration options prior to building the PHP source code.

For example, to build the MySQL extension, mysqli and PDO MYSQL using the MySQL Native Driver, the following command would be given:

./configure --with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

[other options]

As most of the pre-packaged PHP binary installations may not have the support for mysqlnd enabled by default, it is recommended to build PHP and the required database extensions with mysqlnd from the source code

Upgrade PHP 5.1 to 5.3 on CentOS 3

# yum install yum-priorities

# rpm -Uvh
# rpm -Uvh

# yum install httpd

# yum remove php php-*

# yum install php53u-pear php53u php53u-cli php53u-common php53u-devel php53u-gd php53u-mbstring php53u-mcrypt php53u-mysql php53u-pdo php53u-soap php53u-xml php53u-xmlrpc php53u-bcmath php53u-pecl-apc php53u-pecl-memcache php53u-snmp

# vi /var/www/html/phpinfo.php

// Show all information, defaults to INFO_ALL

// Show just the module information.
// phpinfo(8) yields identical results.


# service httpd restart

Finally browse to your phpinfo.php http://x.x.x.x/phpinfo.php and view your newly configured PHP 5.3.3 Apache server.

1 comment:

  1. I tryied it. I didn't find mysqlnd in the list of modules or build Configure Commands. I think CentOS left mysqlnd out of their build.