php with mysqlnd support

You can now get the latest PHP with mysqlnd (MySQL Native Driver) support via remis' yum repository as mentioned in PHP-5.3,-zts-and-mysqlnd. The blog mentions that this is enabld in php-zts. However, no php-pecl extension are available and neither are some of the extensions thread safe. So I went about rebuilding php package from source for mysqlnd support.

  1. Download the source php rpm from http://rpms.famillecollet.com/SRPMS/ . Note, I have used php-5.3.2 which is the latest as of this writing.
  2. Install and apply the below diff patch to the spec file via `patch -p0 < {new_patch_file}` where "new_patch_file" has the below contents:

    --- php-5.3.2-remi.spec.orig 2010-03-11 23:07:04.000000000 -0600
    +++ php-5.3.2-remi.spec 2010-03-11 23:36:03.000000000 -0600
    @@ -24,6 +24,7 @@
    %global phpversion 5.3.2

    # Optional components; pass "--with mssql" etc to rpmbuild.
    +%define with_mysqlnd %{?_with_mysqlnd:1}%{!?_with_mysqlnd:0}
    %define with_oci8 %{?_with_oci8:1}%{!?_with_oci8:0}
    %define with_ibase %{?_with_ibase:1}%{!?_with_ibase:0}
    %if %{?rhel}%{?fedora} > 4
    @@ -677,6 +678,11 @@
    %if %{?fedora}%{?rhel:99} >= 10
        &nbsp;    --with-system-tzdata \
    %endif
    +%if %{with_mysqlnd}
    +    &nbsp;   --with-mysql=shared,mysqlnd \
    +    &nbsp;   --with-mysqli=shared,mysqlnd \
    +    &nbsp;   --with-pdo-mysql=shared,mysqlnd \
    +%endif
    $*
    if test $? != 0; then
       tail -500 config.log
    @@ -704,8 +710,13 @@
        &nbsp;  --enable-dba=shared --with-db4=%{_prefix} \
        &nbsp;  --with-xmlrpc=shared \
        &nbsp;  --with-ldap=shared --with-ldap-sasl \
    +%if %{with_mysqlnd}
    +    &nbsp; --with-mysql=shared,mysqlnd \
    +    &nbsp; --with-mysqli=shared,mysqlnd \
    +%else
        &nbsp;  --with-mysql=shared,%{_prefix} \
        &nbsp;  --with-mysqli=shared,%{_bindir}/mysql_config \
    +%endif
    %ifarch x86_64
        &nbsp;  %{?_with_oci8:--with-oci8=shared,instantclient,%{_libdir}/oracle/%{oraclever}/client64/lib,%{oraclever}} \
    %else
    @@ -725,7 +736,11 @@
        &nbsp;  --enable-fastcgi \
        &nbsp;  --enable-pdo=shared \
        &nbsp;  --with-pdo-odbc=shared,unixODBC,%{_prefix} \
    +%if %{with_mysqlnd}
    +    &nbsp; --with-pdo-mysql=shared,mysqlnd \
    +%else
        &nbsp;  --with-pdo-mysql=shared,%{_prefix} \
    +%endif
        &nbsp;  --with-pdo-pgsql=shared,%{_prefix} \
        &nbsp;  --with-pdo-sqlite=shared,%{_prefix} \
        &nbsp;  --with-pdo-dblib=shared,%{_prefix} \
    @@ -756,6 +771,16 @@
        &nbsp;  --with-recode=shared,%{_prefix}
    popd

    +%if %{with_mysqlnd}
    +without_shared="--without-gd \
    +    &nbsp; --disable-dom --disable-dba --without-unixODBC \
    +    &nbsp; --disable-xmlreader --disable-xmlwriter \
    +    &nbsp; --without-sqlite \
    +    &nbsp; --disable-phar --disable-fileinfo \
    +    &nbsp; --disable-json --without-pspell --disable-wddx \
    +    &nbsp; --without-curl --disable-posix \
    +    &nbsp; --disable-sysvmsg --disable-sysvshm --disable-sysvsem"
    +%else
    without_shared="--without-mysql --without-gd \
        &nbsp;  --disable-dom --disable-dba --without-unixODBC \
        &nbsp;  --disable-pdo --disable-xmlreader --disable-xmlwriter \
    @@ -764,6 +789,7 @@
        &nbsp;  --disable-json --without-pspell --disable-wddx \
        &nbsp;  --without-curl --disable-posix \
        &nbsp;  --disable-sysvmsg --disable-sysvshm --disable-sysvsem"
    +%endif

    # Build Apache module, and the CLI SAPI, /usr/bin/php
    pushd build-apache

  3. Package with:
    rpmbuild -bb --with mysqlnd --define "rhel 5" SPECS/php-5.3.2-remi.spec
    
  4. To install via yum, change to the directory where rpms are located and recreate the repodata via:
    createrepo .
  5. Note: you may need to install some of the missing dependent devel packages. I used a combination of base, epel and remi repository to install the dependencies.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Thanks!

Hi,

thanks for this post - I just used it to build a php 5.3.3 RPM with Mysqlnd from remi's SRPM. I had to apply the changes by hand, but this was nonetheless a useful post for me.

Tom

Comment