Wednesday, June 23, 2010

Adding MSSQL support to PHP on Cpanel server

1) Download FreeTDS

wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

2) Extract
tar zfvx freetds-stable.tgz

3) Configure $ Make

cd freetds-*;

./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld; make ; make install

4) Edit /var/cpanel/easy/apache/rawopts/all_php5

In this version, PHP 5 is the focus hence that specific file.

add the following:

--with-mssql=/usr/local/freetds*If you are using other Builds of Apache or PHP

you may refer to the following for the correct file to edit

instead of /var/cpanel/easy/apache/rawopts/all_php5 such as the case here

* Apache 1.3.x - /var/cpanel/easy/apache/rawopts/Apache1
* Apache 2.0.x - /var/cpanel/easy/apache/rawopts/Apache2
* Apache 2.2.x - /var/cpanel/easy/apache/rawopts/Apache2_2
* All PHP 4.x versions - /var/cpanel/easy/apache/rawopts/all_php4
* All PHP 5.x versions - /var/cpanel/easy/apache/rawopts/all_php5
* Mod_suPHP - /var/cpanel/easy/apache/rawopts/all_suphp
* Specific PHP Version - /var/cpanel/easy/apache/rawopts/PHP-X.X.X

5) Touch the following files as these are what are checked for by PHP. The following error will result if they are not in place.

configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory

Here are the files to create for PHP's conditional check:

touch /usr/local/freetds/lib/libtds.a
touch /usr/local/freetds/include/tds.hp
touch /usr/local/freetds/include/tds.h

If running a 64bit OS and get an error about

configure: error: Could not find /usr/local/freetds/lib64/libsybdb.a|so

you'll need to link a directory or two.

In this example it was an easy fix.

#cd /usr/local/freetds/
#ln -s /usr/local/freetds/lib lib64
#ll /usr/local/freetds/lib64/libsybdb.a
#ll /usr/local/freetds/lib64/libsybdb.so

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

7) Simply build.

/scripts/easyapache

No comments: