Comments on Installing The PHP-MSSQL Module On CentOS 5.0

Installing The PHP-MSSQL Module On CentOS 5.0 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.

9 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: camilord

is it possible both mysql and mssql are in centos 5.x ?

By: Leonardo Bonilla

Salutes form Colombia

When I have to make the modification to "php.spec" file i see that you have a missing at the begining of the text 1 line

"%package mssql" 

I just add this to your info and all works, y have Centos 5.1 and PHP 5.1.6-20

Regards

 Leonardo

By: Hugh MacMullan

I concur with Leonardo (the missing '%package mssql' bit).

After that works great on Red Hat EL 5.4 with AppStack and PHP 5.2.10.  Nice!

By: Leonardo

Hi, I have problem in this line:

rpmbuild -bb ./php.spec

 Show me this error:

Bad exit status from /var/tmp/rpm-tmp.60284 (%build)

Each time that I execute this command rpm... The number error is diferent.

By: Vikram Ghotgalkar

1. Install php-mmsql module using yum

yum install php-mssql

2. Add the following line to php.ini

extension=mssql.so

3. Restart Apache

/etc/init.d/httpd restart

 

:)

By: Anonymous

Vikram,

 You do realize that the entire point of this article is that php-mssql is not available in the default yum repositories?

By: jackocnr

Not sure if the article is useful for some other reason - some other constrained set of circumstances, but this quick solution worked for me, thanks!

By: ifatreee

  I've had to use your instructions a couple of times now (thanks, BTW!) and this is the one-liner I keep rewriting to do the rpmbuild dependencies.
 
"If you are asked for some dependencies, just yum install them":
 
rpmbuild -bb ./php.spec 2>&1|grep 'is needed'|awk '{print $1}'|while read n; do yum -y install $n; done
 
 Hopefully someone else will find that useful when they're presented with a list of 25 things to install. ;)

By: mchaney

Ok, I have had/Still having some issues with the guide and thought I would add my comments and changes:.

1.) # Grab your specific RPM and install it:

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm
rpm --install rpmforge-release-*.rpm

Failed for me with a 404 cant find error.

What I actually had to do was to install the actual correct package. I got this from:

http://www.rpmrepo.org/RPMforge/Using

Once I had downloaded the correct release and it installed I could proceed.

2.) # yum install php-devel

Failed for me due to dependancy. What it actually turned out was that I had a non standard centos installation of PHP. I then found this forum:

https://www.centos.org/modules/newbb/viewtopic.php?viewmode=flat&topic_id=27460&forum=38

And followed the link and the guide that can be found at :

http://www.jasonlitka.com/yum-repository/

(Basically create a file /etc/yum.repos.d/utterramblings.repo and in it put:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

)

This then installed/yum installed the php-devel ok.

3.) # If you don't have the php.spec file, you can download the php src rpm.

vi /usr/src/redhat/SPECS/php.spec

I dont have that php.spec file and the link for the wget fails with a 404 error.

Instead I took off the file extension and went to http://centos.mirrors.skynet.be/pub/centos/5/os/SRPMS/

And found the php.src file that way instead. I then did the rpm install (note its not -install but --install (two dashes)). My php.spec file then appeared.

4.) # Start building your php rpm:

rpmbuild -bb ./php.spec

Failed because I didnt read the comment about adding %package mssql.

5.)  # If you are asked for some dependencies, just yum install them.

make sure you do the

rpmbuild -bb ./php.spec 2>&1|grep 'is needed'|awk '{print $1}'|while read n; do yum -y install $n; done
 
from the comment as there are loads of dependancies.
 
However I then had to build the php.spec file again with

rpmbuild -bb ./php.spec

6.) My modules for mssql.so are in usr/lib/php/modules. My php.ini is in etc/php.ini.
 
I restarted my apaches server and went to phpinfo and...........................
 
It now supports mssql....my code no longer says invalid function/unknown function
 
Ok, it cant actually connect to the db or server yet, but one step at a time.