Installing The PHP-MSSQL Module On CentOS 5.0
Author & Content by Tim Haselaars (http://www.trinix.be)
As you might have noticed on Centos 5.0, there is no PHP-MSSQL module/extension available in the default yum repositories. So if you want to use it you can alter the PHP binary or you can compile an mssql module/extension. In this article I will explain how to compile the mssql module/extension.
You need to activate the RPMForge custom repository (formely known as Dag Wieers): http://dag.wieers.com/rpm/packages/rpmforge-release/
Grab your specific RPM and install it:
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm
rpm --install rpmforge-release-*.rpm
Next step is to install freetds, freetds-devel, php-devel, and the Development tools.
yum groupinstall ‘Development Tools’
yum install freetds freetds-devel --enablerepo=rpmforge
yum install php-devel
Next we alter the php.spec file, which contains the php configuration for compiling.
vi /usr/src/redhat/SPECS/php.spec
If you don't have the php.spec file, you can download the php src rpm.
wget centos.mirrors.skynet.be/pub/centos/5/os/SRPMS/php-5.1.6-5.el5.src.rpm
and next
rpm –install php-5.1.6-5.el5.src.rpm
And then do an updatedb and locate php.spec.
Edit the CFLAGS= line (~line 310) of the php.spec file - remove -Wno-pointer-sign. Then add the following piece of code to it:
Group: Development/Languages Requires: php = %{version}-%{release}, php-pdo Summary: A module for PHP applications that use the MSSQL database. provides: php_database BuildRequires: freetds-devel %description mssql The MSSQL package contains a dynamic shared object that will add support for accessing MSSQL databases to php.
Start building your php rpm:
rpmbuild -bb ./php.spec
If you are asked for some dependencies, just yum install them.
cd /usr/src/redhat/BUILD/php-5.1.6/ext/mssql/
Now we are going to make the mssql module without having to rewrite the php binary:
phpize
./configure --with-mssql
make
make install
Next look for the mssql.so file and make sure it is in the module directory specified in your php.ini. Copy it to the specified location if needed.
Final Step
vi /etc/php.ini
Add this line to your php.ini:
extension=mssql.so
Save the php.ini and restart Apache:
/etc/init.d/httpd restart
Et voilà you have just made your mssql module/extension without having to change anything in the base CentOS 5 HTTPD/PHP setup.