Centos 5 : Install PHP-MSSQL Module / Extension

Centos, Linux, PHP Add comments

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

24 Responses to “Centos 5 : Install PHP-MSSQL Module / Extension”

  1. Rene Says:

    I don`t have the php.spec ?!?!?!

  2. thim Says:

    Try to do a “locate php.spec”

    Make sure you have the devel or src installed.
    ( yum install php-devel )

  3. Joe Says:

    I have the same problem

    php-devel is installed

    updatedb, locate php.s* gat 0 results
    nee help pls..

  4. thim Says:

    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.

  5. Rosita Fraguel Says:

    Thanx a lot!

    I have saved a lot of time with your help!

  6. Joe Says:

    thim thanx for help

  7. thim Says:

    Always glad to help.

    For more questions or request please don’t hesitate.

  8. Joe Says:

    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

  9. thim Says:

    What do you mean joe?

  10. Jason Says:

    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

  11. thim Says:

    mmm this is very strange.

    You have installed Apache and PHP from YUM?

    The warning can be ignored of the mockbuild can be ignored

  12. tuxl0ver Says:

    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

  13. tuxl0ver Says:

    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..

  14. Ruben Says:

    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.

  15. Devil’s Place » Blog Archive » Centos 5 : Install PHP-MSSQL Module / Extension Says:

    [...] original post: http://thim.trinix.be/2007/06/06/centos-5-install-php-mssql-module-extension/ [...]

  16. Thim Says:

    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.

  17. evil_steve Says:

    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

  18. Valsha Says:

    rpmbuild -bb ./php.spec
    cat: /usr/include/httpd/.mmn: No such file or directory
    error: line 190: Package does not exist: %description mssql

  19. thim Says:

    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.

  20. thim Says:

    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

  21. evil_steve Says:

    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.

  22. thim Says:

    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.

  23. Martín lugo Says:

    :grin:
    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

  24. Rubén Ortiz » PHP MSSQL para Centos 4 sobre Plesk Says:

    [...] http://thim.trinix.be/2007/06/06/centos-5-install-php-mssql-module-extension/ [...]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in