Posts tagged Enable PHP MSSQL Extension on cpanel Linux Server

How To Enable PHP MSSQL Extension on cpanel Linux Server

If you want to enable the PHP-MSSQL extension on a CPanel linux server then follow the below steps :

Module’s Required to be installed :

1) unixODBC :

UnixODBC is an open source project that implements the ODBC API.

ODBC is an open source project for providing application developers with a predictable API with which to access Data Sources. Data Sources include SQL Servers and any Data Source with an ODBC Driver.

2) freeTDS :

FreeTDS is a free application programming library, a re-implementation of the Tabular Data Stream protocol.

FreeTDS comes with a low level library (the TDS layer) along with a number of APIs (Application Programming Interfaces). The APIs are DB-Lib, CT-Lib, and ODBC.

3) PHP mssql.so

PHP-MSSQL is used to create the programs or applications with the MsSql database functionality.

Installation :

Install unixODBC package

root@server[#] wget http://www.unixodbc.org/unixODBC-2.3.0.tar.gz
root@server[#] tar -zxf unixODBC-2.3.0.tar.gz
root@server[#] cd unixODBC-2.3.0
root@server[#] ./configure -prefix=/usr/local -enable-gui=no
root@server[#] make
root@server[#] make install

Install freeTDS package

You can install freeTDS either via yum or from a tar.gz file

Installation via yum

root@server[#] yum install freetds*

Installation via tar.gz file

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

Normally you don’t need to configure it, as it automatically takes the default structure, but still you can configure it as

Add entry in freetds.conf
[MyServerHOSTNAME]
host = MyServerHOSTNAME
port = 1433
tds version = 8.0

Now configure the mssql.so

root@server[#] cd /home/cpeasyapache/src/php-5.2.13/ext/mssql
root@server[#] phpize
root@server[#] ./configure
root@server[#] make
root@server[#] make install

Then need to Enable the mssql extension in the php.ini

Usually it automatically enables the extension but if not then you can enable it manually as :

root@server[#] echo “extension=mssql.so” >> /usr/local/lib/php.ini

Finally restart the Apache service

root@server[#] /etc/init.d/httpd restart

That’s all you are done.