Install PHP 5.6 MSSQL Freetds extension on CWP Linux server

In this article we’ll install Freetds for php 5.6 On CWP control panel. FreeTDS is a set of libraries for Linux that allows your programs to natively talk to Microsoft SQL Server. Using Freetds we can connect php code in Linux to Microsoft Sql Server.

First install Freetds :

cd /usr/local/src
wget ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz
tar zxvf freetds-current.tar.gz
cd freetds-dev*
./configure --prefix=/usr/local/freetds --enable-msdblib
make && make install
cp include/freetds/tds.h /usr/local/freetds/include
cp src/tds/.libs/libtds.a /usr/local/freetds/lib
echo "/usr/local/freetds/lib" >> /etc/ld.so.conf
echo "export FREETDSCONF=/usr/local/freetds/etc/freetds.conf" >> /etc/profile
ln -s /usr/local/freetds/lib /usr/local/freetds/lib64

Freetds config file is in (you need to edit the mssql details here in this conf) :

/usr/local/freetds/etc/freetds.conf

Then build php 5.6 with this option flag :

--with-mssql=/usr/local/freetds

OR

You can also add this config to CWP php “5.6.ini” via “Manual Options” and add it at the end of the file (PHP selector and php-fpm only) :

[mssql]
default=0
option="--with-mssql=/usr/local/freetds"
info-file=config-scan.txt

** if you didn’t see the mssql option in php option manager under cwp then reset the options “Reset Options“.

**** for php switcher you need to edit php option ini file manually from sftp/ssh to add the config option at the end of the file, ini location is listed below.

CWP php options ini file location :

##For switcher
/usr/local/cwpsrv/htdocs/resources/conf/php_switcher

##For selector
/usr/local/cwpsrv/htdocs/resources/conf/php_selector

##For PHP-FPM
/usr/local/cwpsrv/htdocs/resources/conf/php-fpm_selector

You can check the mssql is installed or not via phpinfo or via command line

php -m | grep mssql
or 
Via PHP INFO
Back to top button