Connect to MS SQL Server via Linux Apache PHP

Connect to MS SQL Server via Linux Apache PHP

Connecting from a Linux Box based Apache PHP to Windows MS SQL server might be a rare scenario but if you want to achive that without recompiling PHP and Apache, here is what to do:

1. Go to http://www.freetds.org/ and download the latest package. Unpack it, change to the directory where the sources are located and

# ./configure –prefix=/usr/local/freetds –enable-msdblib
# make
# make install

2. Check your PHP version on your server. If you don t know how, look at this

https://mediatemple.net/community/products/dv/204643880/how-can-i-create-a-phpinfo.php-page

3. Download the same PHP sources package. Go to http://php.net/releases/ and get the sources.

Unpack, locate /ext folder and make sure there are the following subfolders : /mssql ( in case you are still used to old mysql_ functions ) and /pdo_dblib if you user PDO style development.

4. Go into /mssql folder and :

# phpize
# ./configure –with-mssql=/usr/local/freetds
# make
# make install

This will create mssql.so extension and put it in your php extension dir

5. Go into /pdo_dlib and :

# phpize
# ./configure –with-pdo-dblib=/usr/local/freetds
# make
# make install

This will create pdo_dblib.so extension and put it in your php extension dir

6. Edit php.ini , find extensions section and add

extension=mssql.so

extension=pdo_dblib.so

7. Restart the web server ( httpd )

Reed the next post for some hints

About the Author

Mircea Dragota este manager de proiecte si membru al echipei de dezvoltatori CCMS

Comentariu

Your email address will not be published.