As you might have noticed since Centos 5.0, the PHP-MSSQL module / extension isn’t default available in the yum repository. So if you want to use it you can alter the PHP binairy or you can compile an mssql module / extension. In this howto 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-*.rpmrpm –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, containing the php configuration for compiling.
vi /usr/src/redhat/SPECS/php.spec
if you can’t find 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.rpmand 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”
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 has is asking for some dependancies 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 binairy.
phpize
./configure –with-mssql
make
make install
Next look for the mssql.so and make sure it is in the module directory specified in your php.ini.
and copy it to the specified location if needed.
final step
vi /etc/php.ini
add this line to php.ini
extension=mssql.so
save php.ini and restart apache
/etc/init.d/httpd restart
éh voila you have just made your mssql module / extension without having to change anything to the base Centos 5 HTTPD / PHP setup.
PS: I have also posted this howto on http://www.howtoforge.com
June 12th, 2007 at 11:40
I don`t have the php.spec ?!?!?!
June 12th, 2007 at 12:49
Try to do a “locate php.spec”
Make sure you have the devel or src installed.
( yum install php-devel )
June 14th, 2007 at 16:29
I have the same problem
php-devel is installed
updatedb, locate php.s* gat 0 results
nee help pls..
June 14th, 2007 at 20:58
You can download the php src rpm.
wget http://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.
This should do the trick.
June 15th, 2007 at 10:09
Thanx a lot!
I have saved a lot of time with your help!
June 15th, 2007 at 11:08
thim thanx for help
June 15th, 2007 at 11:11
Always glad to help.
For more questions or request please don’t hesitate.
June 15th, 2007 at 11:13
if you can edit also this >
%package mssql
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
June 15th, 2007 at 11:29
What do you mean joe?
July 27th, 2007 at 10:49
After remove the “-Wno-pointer-sign” And add those piece of code.
And do the rpmbuild -bb ./php.spec
I have got the follow problem:
cat: /usr/include/httpd/.mmn: No such file or directory
error: line 370: Package does not exist: %description mssql
P.S. Before I install the php-5.1.6-5.el5.src.rpm with many warning as follow:
warning: user mockbuild does not exist – using root
warning: group mockbuild does not exist – using root
Please help
July 28th, 2007 at 22:16
mmm this is very strange.
You have installed Apache and PHP from YUM?
The warning can be ignored of the mockbuild can be ignored
August 27th, 2007 at 22:21
Hey I just installed this on Centos 5 with php-5.1.6-12.el5.
you have to do a # of things to get it to work.
1 This code is right:
But you need add the following piece of code to php.spec above – Group: Development/Languages
%package mssql
2 You have to install alot of dependencies if you have a minimal install.
3 My install failed looking for /usr/lib/libtds.a and libtds.o which were in /usr/lib64 dir I quick fixed with a ln -s /usr/lib/libtds.a –> /usr/lib64/libtds.a and one for the libtds.o too.
configure worked fine then and everything went well…
module is active and operational.
enjoy tuxl0ver
August 27th, 2007 at 22:24
Oh Almost forgot make all the top level source directories as if you had a whole kernel there or the SOURCES will not install php-$version.tar.gz in the dir. I had to redo it when the path failed during phpize.
tuxl0ver..
November 23rd, 2007 at 11:37
Hello Thim
im using Centos 5 and i need to install MSSQL module. But in DAG RPM Package link writed in your tutorial there are not any package for Centos 5. There are only to Fedora and Red Hat. So which package i must download ?
Excuse me by a possible stupid question.
Thanks a lot.
December 29th, 2007 at 16:38
[...] original post: http://thim.trinix.be/2007/06/06/centos-5-install-php-mssql-module-extension/ [...]
January 30th, 2008 at 10:48
Ruben,
Centos is a Redhat based linux distribution, so in the DAG RPM repository always choose for the Redhat RPM’s if there are not Centos RPM’s available.
February 27th, 2008 at 08:56
Hi Thim
Do you happen to know what I need to add to the spec file to get it to create a php-mssql.rpm file? I have ~25 servers I need this for, and while they do tend to have cycles to spare, I’d rather make it once and not have to recreate this every time I need php-mssql on a server.
thanks
March 1st, 2008 at 17:00
rpmbuild -bb ./php.spec
cat: /usr/include/httpd/.mmn: No such file or directory
error: line 190: Package does not exist: %description mssql
March 3rd, 2008 at 20:29
evil_steve: normally if all your server are configured the same you simple just 1 RPM and then share it on all the other servers or just put in a local YUM repository.
Make sure that the RPM is build and can be installed without any problems.
March 3rd, 2008 at 20:31
Valsha, check that you copied the code correctly.
I noticed that my wordpress lay-out messes up a lot of code.
You can double check my howto on http://www.howtoforge.com
March 4th, 2008 at 00:52
Hi Thim
I know that part, the problem is that if I go into the /usr/src/redhat/RPMS/i386 directory, there are the rebuilt rpm’s for all the packages *but* the mssql one. I would like the spec file to create a mssql rpm file, but at the moment it just gives me the module in a folder ready to configure, compile and install.
March 4th, 2008 at 20:44
I don’t know how the module can be put in an RPM and currently I don’t have a linux server at my disposal to do the experimenting on.
Perhaps you can contact the guys at howtoforge.com for more help.
March 11th, 2008 at 17:34
Excelente manual, segui al pie de la letra y funcionó
solo tengo que dar 3 detalles:
1.- cuando adicionan al php.spec
************************************
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
***************************************
Al inicio deberian de poner %package mssql
pues no reconocera el moulo, entonces deberia de quedar asi:
******************************
%package mssql
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
****************************
2.- el comando phpize funciona si tiene instalado el paquete php-devel por lo tanto hacer
*************
yum -y install php-devel
**********************
3.- Si no encuentram el archivo php.spec descargar el archivo php-5.1.6-12.el5.src.rpm e instalarlo, yo lo descague de aqui:
http://mirror.mcs.anl.gov/pub/scientific-linux/5x/SRPMS/vendor/
pues el que figura en el manual ya no existe.
saludos
Martín
May 27th, 2008 at 10:40
[...] http://thim.trinix.be/2007/06/06/centos-5-install-php-mssql-module-extension/ [...]