Howto: Installing GnuPG for php 5.3 on Centos6

Posted on Updated on

What is GnuPG ?

GNU Privacy Guard(gnupg) is a cryptographic software mostly used for Filecrypt, it is available for the following tools bash,php,python,perl modules. The statergy for using GnuPG is to be secure the data while digital transportation.

Please refer the Wiki for more information :

I followed the below steps to install GnuPG.

1, Install Dependency packages gnupg libgpg-error gpgme libgpg-error-devel gpgme-devel
2, Install/Enable PHP module
3, Restart Apache

Install dependencies:

[root@planetcure:~]# yum install gnupg libgpg-error gpgme libgpg-error-devel gpgme-devel php-devel

Installing PHP module using PECL repository

[root@planetcure:~]# pecl install gnupg

Enabling php support

[root@planetcure:~]# echo -e '; Enable GnuPG extension module\' > $(php --ini | grep "additional .ini" | awk -F: '{print $2}')/gnupg.ini

Verifying installation

[root@planetcure:~]# php --info | grep gnupg
gnupg support => enabled

Restarting Httpd

[root@planetcure:~]# service httpd restart

If you need to check through PHP info , create a file info.php with the below code and place it into the web root directory. then call the file through browser it will be looks like the below image.

cat info.php



ERROR: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

Posted on Updated on

One of our server getting odbc_connection error after migration, this will usually  happens because ODBC module has not enabled on the server,  While I tried to set up ODBC with freeTDS in order to connect to a MSSQL server faced several issues.

MSSQL uses Tabular Data Stream (TDS) as a communication protocol which is same like in Sybase. freeTDS is an implementation of TDS protocol.

Before trying to connect with freetds to the mssql server, make sure, that your MSSQL server has remote access to connect.

[02-May-2013 02:21:31 America/Denver] PHP Warning: odbc_connect() [<a href='function.odbc-connect'>function.odbc-connect</a>]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /home/anand/public_html/mssql2000.php on line 69

We need below packages installed to get this done.

1, php-odbc
2, unixODBC
3, freetds

Installation : 

#pecl  install php-odbc
#yum install unixODBC-devel unixODBC freetds-devel freetds


Download unixODBC and untar it

#tar –xzf unixODBC-2.3.0.tar.gz
#cd unixODBC-2.3.0 ; ./configure ; make ; make install

Installing freeTDS
Set environmental variable at /etc/profile. Add following lines at end

#vi /etc/profile
 # TDS
#tar –xzf freetds*.tar.gz ; cd freetds* ; ./configure --with-tdsver=8.0 --with-unixodbc=/usr/local ; make ; make install

Note: tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0, More info about freetds.conf here

root@server [~]# cat /etc/freetds.conf
host = 11.222.333.44
port = 1433
tds version = 8.0

Setup ODBC:
Create template for both driver and configuration. before creating make sure that the driver files are valid.

root@server [~]# vi tds.driver.template
#Driver for MS SQL
[FreeTDS]                       #"FreeTDS" is the unique name for this driver
Description = FreeTDS driver
Driver = /usr/lib64/
Setup = /usr/lib64/
FileUsage = 1
UsageCount =1

root@server [~]# vi tds.datasource.template
[MSSQL]               #"MSSQL" is the DSN name that we call to connect database
Driver = FreeTDS      # name that we specified in the driver file
Description = MSSQL ReflectiveLearning
Trace = No
TraceFile = /var/log/freetds.log
Servername = MSSQLSERVER    # this  name specified in the freetds.conf
Port = 1433
Database = reflective_Live
TDS_Version = 8.0
 Now install the data source and driver

The below commands will create configuration file for odbc but odbc.ini has create in users home dir by default we have to move it manually to /etc/

odbcinst -i -d -f tds.driver.template
odbcinst -i -s -f tds.datasource.template
cp -rpf ~/.odbc.ini /etc/odbc.ini
mv /etc/odbc.ini /usr/local/etc
mv /etc/odbcinst.ini /usr/local/etc
cd /etc
ln -s /usr/local/etc/odbc.ini
ln -s /usr/local/etc/odbcinst.ini
chmod 0664 /usr/local/etc/odbc*.ini
cd ~

check by using command line
#tsql -H Hostname_OR_IP -p PortNumber -U Username

root@server [~]# isql -v DSNname Username 'Password'
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
SQL> quit
That’s all, now the application will works fine.
some PHP code to connect to it
//Open Database Connection
$cn = mssql_connect($dbserver,$dbusername,$dbpassword) or die("Connection Error");
$db = mssql_select_db($defaultdb,$cn) or die("Database Error");
echo "Connection Success"

Some of the useful commands,

odbcinst -j         # to check the ODBC version and configuration.
odbcinst -q -d   # View loaded drivers.
odbcinst -q -s   # View DSN entry
tsql -LH   #To list MSSQL server instant name,version etc.,
osql -S DSN -U Username -P ‘Password’ #list the configuration files loaded to connect ODBC

Install / Enable PHP MsSQL Extension in cPanel/WHM Server

Posted on

For enabling mssql support in PHP on cpanel/WHM installed server we can’t use easyapache in this case,  we need FreeTDS installed and configured which is a set of Unix/Linux libraries that implement the TDS protocol. First we will need to download and install FreeTDS, you can find more information and download link at URL. Note the exact installation steps below :

Packages :
1. unixODBC
2. freeTDS
step :1  unixODBC

yum install  unixODBC unixODBC-devel

Step :2  freeTDS

cd /usr/local/src
tar zfvx freetds-stable.tgzcd freetds-*;
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld; make ; make install 
echo "--with-mssql=/usr/local/freetds" >> /var/cpanel/easy/apache/rawopts/all_php5
touch /usr/local/freetds/lib/libtds.a
touch /usr/local/freetds/include/tds.h

Use this line if you get any error like no such file or directory

ln -s /usr/include/sqlext.h /usr/local/include/sqlext.h

If it it is a 64 bit server then make the following softlink

ln -s /usr/local/freetds/lib/  /usr/local/freetds/lib64

Step :3

Now run Easy Apache and make sure that Mysql, Mysql of the system, amd Mysqli are all selected.


 Now you can check Mysql enabled

root@server [~]# php --info |grep  "mssql"
MSSQL Support => enabled

Howto: Installing Imagick on PHP

Posted on Updated on

I have recently been installing ImageMagick on my server for use on my other site

First to install ImageMagick:

tar zxvf ImageMagick.tar.gz
cd ImageMagick-
./configure --prefix=$HOME/local -with-gslib --with-gs-font-dir=/usr/share/fonts/type1/gsfonts/ --without-perl
make install
Usually you would use --with-perl-options but for some reason versions of ImageMagick after 6.4.5 don’t , You don’t really need it when using ImageMagick with PHP anyway.

Installing Imagick

Installing Imagick. It took a little bit of time but I managed to get it installed. You first need to download, compile & install autoconf & then Imagick.

mkdir ~/source
cd ~/source
tar xzf autoconf-2.63.tar.gz
cd autoconf-2.63
./configure --prefix=$HOME/source
nice -n 19 make
make install
export PATH=/home/{username}/source/bin:$PATH
cd ~/
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2
./configure -prefix=$HOME/imagick --with-imagick=$HOME/local --with-php-config=$HOME/php5/bin/php-config
make install
Don’t forget to change {username} on line 9 to your username or you’ll get a error.
After that it should tell you the path to which you need to instuct your PHP.ini to find. Scroll all the way down until you find extension_dir='./' and change it to the FULL.
path to the folder given by the build of imagick before. Now find the list of extensions which look like ‘;extension=thing_some.dll’ and after the last one add ‘’. Now press ESC then colon ‘w’ ‘q’ and enter to quit and save.

Howto: Installing mcrypt, mhash on Apache with PHP5

Posted on Updated on

Get and Install mhash

or go to sourceforge and find the latest.
tar -xvzf mhash-0.9.9.tar.gz
cd mhash-0.9.9
./configure --prefix=/usr/local/mhash
make install

Get and install libmcrypt


tar -xvzf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt --disable-posix-threads
make install

Get and install mcrypt.


or go to source forge and get the latest.

tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
make install

Create the mcrypt php5 module to load.

Find you source code for your php version.


find / -name "php"

mine was found here

cd to php-5.2.6/ext/mcrypt
make clean
make install

If you are using a 64 bit computer, create a symbolic link.

cd /usr/lib64/modules
ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20050922/ ./

Create a new file named in /etc/php.d directory and enter the following.

;Enable mcrypt extension module

Create the mhash extension:

cd to php-5.2.6/ext/mhash
make clean
make install
cd /usr/lib64/modules
[root modules]# ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20050922/ ./

Create a new file named in /etc/php.d directory and enter the following.

;Enable mhash extension module

Bounce Apache

[root /]#service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Check Apache for mcrypt loaded.
Move to your website loaction and create a file named phpinfo.php and enter.


Now open a brower and point it to your site /phpinfo.php

PHP 5.3 installation on CentOS 5.5

Posted on Updated on

To install, first you must tell rpm to accept rpm’s signed by me, then add the yum repository information to yum:

rpm -Uvh
yum --enablerepo=webtatic install php
yum --enablerepo=webtatic update php


Package Provides
php mod_php
php-cli php-cgi, php-pcntl, php-readline
php-common php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php-embedded php-embedded-devel
php-mssql php-pdo_dblib
php-mysql php-mysqli, php-pdo_mysql, php_database
php-odbc php-pdo_odbc, php_database
php-pgsql php-pdo_pgsql, php_database
php-process php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php-xml php-dom, php-domxml, php-wddx, php-xsl

“Depsolving” problems

If you get depsolving problems when updating, you may have currently installed some extensions that have been removed, e.g. php-mhash, php-ncurses.

You will need to remove them before upgrading.

yum remove php-mhash php-ncurses

Howto : Enabling memcached extension on php.

Posted on Updated on

Memcached is a general-purpose distributed memory caching system, but is now used by many other sites. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. Memcached runs on Unix, Windows and MacOS and is distributed under a permissive free software license.

Installation :

You may simply install mamcached using pacl library, but it need the dependency package libmencached download , When compailing you might got an error mamcached not found so tha you may use some parameters with configuring like  –without-memcached

error Output:

checking for memcached session support... enabled
checking for memcached igbinary support... disabled
checking for memcached location... configure: error: libmemcached support requires libmemcached. Use --with-memcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
ERROR: `/tmp/pear/temp/memcached/configure' failed

Step :1- (Libmamcached Installation )

1.# wget
2.# tar -zxvf libmemcached-0.50.tar.g
3.# cd libmemcached-0.5
4.#./configure --without-memcached && make && make install

Step:2 (Memcached installation)

1.#pecl install memcache
2.#echo "extension=/usr/lib/extensions/no-debug-zts-20060613/" >> /etc/php.ini

Success Output :

Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2" install
Installing shared extensions:     /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr/lib/extensions/no-debug-zts-20060613/
running: find "/tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2" | xargs ls -dils
1974089   4 drwxr-xr-x 3 root root   4096 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2
1974111   4 drwxr-xr-x 3 root root   4096 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr
1974112   4 drwxr-xr-x 3 root root   4096 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr/lib
1974113   4 drwxr-xr-x 3 root root   4096 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr/lib/extensions
1974114   4 drwxr-xr-x 2 root root   4096 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr/lib/extensions/no-debug-zts-20060613
1974110 180 -rwxr-xr-x 1 root root 184221 2011-07-27 11:17 /tmp/pear/temp/pear-build-rootmdfn1M/install-memcached-1.0.2/usr/lib/extensions/no-debug-zts-20060613/

Build process completed successfully
Installing '/usr/lib/extensions/no-debug-zts-20060613/'
install ok: channel://
configuration option "php_ini" is not set to php.ini location
You should add "" to php.ini

Thats it..