Monday, August 30, 2010

How to install mssql php extension on linux or cpanel server?

Guys,

Following modules are need to be installed before enabling the MSSQL extension for PHP on server.

--------
a) unixODBC
b) freeTDS
c) PHP mssql.so
---------

Setup 1: Install unixODBC package :

----------------
# wget http://www.unixodbc.org/unixODBC-2.2.14-p2.tar.gz //You can download latest tar file
# tar -xvzf unixODBC-2.2.12.tar.gz
# cd unixODBC-2.2.12
# ./configure -prefix=/usr/local -enable-gui=no
# make
# make install
----------------

Step 2: Install freeTDS package :

---------------
#wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
# tar -xvzf freetds-stable.tgz
# cd freetds-0.82
# ./configure -with-tdsver=8.0 -with-unixODBC=/usr/local
# make
# make install
---------------

Step 3: Configuration freeTDS : -

---------------
#cd freetds-0.82
# vi freetds.conf file and add the entry for the MS SQL server.

Quote:
[MSHOSTNAME]
host = MSHOSTNAME //hostname or IP address of mssql server
port = 1433 //port of the mssql server, default 1433
tds version = 8.0
----------------

Step 4: Getting the mssql.so file :

-----------------
In Cpanel servers the extensions are located in

# cd /home/cpeasyapache/src/php-5.2.9/ext/mssql/
# phpize
# ./configure
# make
# make install
-----------------

This commands will automatically create a copy of mssql.so in the installed extension in the following folder.

-----------------
/usr/local/lib/php/extensions/no-debug-non-zts-20060613
-----------------

Now do the following :
php -i |grep php.ini //to find out global php.ini on the server.

# echo "extension=mssql.so" >> /usr/local/lib/php.ini

Step 6: Restarting Apache Server!

# /etc/init.d/httpd restart
-----------------

That's it. Try :)

1 comment:

  1. Kamal,

    Thanks for the post. Good one.

    Prajith

    ReplyDelete