/Dev/Zero Linux

Compile php 5.3 on Centos 7 from RPM

Nov
05

Updated 5/7/2019

I recently had to build php 5.3.29 on a brand new Centos 7 Digital Ocean droplet.

Pretty simple process but I thought it would be a good idea to share my steps…

This will be a general simple to follow how-to on a brand new centos 7.x machine.

  1. Install the epel repo and rpm tools.

sudo yum -y install epel-release rpm-build rpmdevtools wget

  1. install the Centos development tools and libraries.

sudo yum -y groupinstall “Development Tools” “Server Platform Development” “Additional Development” “Compatibility libraries”

sudo yum -y install db4-devel pam-devel libedit-devel libtool-ltdl-devel libc-client-devel sqlite2-devel t1lib-devel libmcrypt-devel libtidy-devel freetds-devel aspell-devel recode-devel enchant-devel

  1. Setup the rpm build directory environment. 

cd ~

rpmdev-setuptree

  1. Download the Centos 6 src rpm and rebuild it.

This rpm is based on the php-5.3.23-1.el6.remi.src.rpm that I modified to include the latest version of php 5.3 (5.3.29) and also fixed any pathing issues between Centos 6 and Centos 7.

wget https://dev-zero.org/files/php-5.3.29-1.el7.src.rpm

rpmbuild –rebuild php-5.3.29-1.el7.src.rpm

When the process is done you will have your Centos 7 php 5.3.29 rpm’s.

Wrote: ~/rpmbuild/RPMS/x86_64/php-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-cli-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-fpm-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-common-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-devel-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-imap-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-ldap-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-pdo-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-sqlite-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-mysql-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-mysqlnd-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-pgsql-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-process-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-odbc-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-soap-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-snmp-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-xml-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-xmlrpc-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-mbstring-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-gd-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-bcmath-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-dba-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-mcrypt-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-tidy-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-mssql-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-embedded-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-pspell-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-recode-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-intl-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-enchant-5.3.29-1.el7.x86_64.rpm
Wrote: ~/rpmbuild/RPMS/x86_64/php-debuginfo-5.3.29-1.el7.x86_64.rpm

All you have to do now is install them via yum.

7 Responses to Compile php 5.3 on Centos 7 from RPM

  1. Thank for your tutorial, however I am experiencing some issues.
    See below.

    #rpmbuild –rebuild php-5.3.29-1.el7.src.rpm
    Installing php-5.3.29-1.el7.src.rpm
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: user mayday does not exist – using root
    warning: group mayday does not exist – using root
    warning: bogus date in %changelog: Sat Sep 25 2011 Remi Collet 5.3.8-5
    warning: bogus date in %changelog: Wed Mar 29 2011 Remi Collet 5.3.6-2
    warning: bogus date in %changelog: Tue Apr 26 2010 Remi Collet 5.3.2-2
    warning: bogus date in %changelog: Thu Mar 5 2010 Remi Collet 5.3.2-1.###.remi
    warning: bogus date in %changelog: Tue Aug 20 2008 Remi Collet 5.3.0-0.1.alpha2-dev.200808200630.fc9.remi
    warning: bogus date in %changelog: Sat May 11 2008 Remi Collet 5.2.6-2.###.remi
    warning: bogus date in %changelog: Sat Jul 24 2006 Remi Collet 5.1.4-3.fc{3,4,5}.remi
    error: Failed build dependencies:
    mysql-devel >= 4.1.0 is needed by php-5.3.29-1.el7.x86_64
    net-snmp-devel is needed by php-5.3.29-1.el7.x86_64

    I will try a bit more in the meantime. But maybe you have a solution or idea?

    Thanks in advance.

    Regards

  2. Well a small update. I fixed the missing dependencies by using:

    yum install mysql-community-devel*
    yum install net-snmp-devel-*

    rpm -qa |grep mysql-community-devel*
    mysql-community-devel-5.6.44-2.el7.x86_64
    rpm -qa |grep net-snmp-devel-*
    net-snmp-devel-5.7.2-37.el7.x86_64

    But it stops here now:

    checking for mcrypt support… no
    checking for MSSQL support via FreeTDS… no
    checking for MySQL support… yes, shared
    checking for specified location of the MySQL UNIX socket… no
    checking for mysql_close in -lmysqlclient… yes
    checking for MySQL UNIX socket location… no
    checking for MySQLi support… yes, shared
    checking whether to enable embedded MySQLi support… no
    mysql_config not found
    configure: error: Please reinstall the mysql distribution
    error: Bad exit status from /var/tmp/rpm-tmp.xpQ5KT (%build)

    However: locate mysql_config
    /usr/bin/mysql_config
    /usr/bin/mysql_config-64
    /usr/bin/mysql_config_editor
    /usr/share/man/man1/mysql_config.1.gz
    /usr/share/man/man1/mysql_config_editor.1.gz

    I will reinstall MySQL, maybe that will help?

  3. Well after try number XX I decided to do the following:

    cp /usr/bin/mysql_config /usr/lib64/mysql/

    And re-ran: rpmbuild –rebuild php-5.3.29-1.el7.src.rpm
    Which seemed to work now? 🙂

  4. Do you have the rpm source checked into github/gitlab/anywhere else?

    I’m in a similar situation, but getting build errors from your rpm during the prep phase:

    patching file ext/fileinfo/tests/mime_content_type_001.phpt
    File ext/fileinfo/tests/resources/dir.zip: git binary diffs are not supported.
    error: Bad exit status from /var/tmp/rpm-tmp.vaG7Tu (%prep)

    There’s also a missing dependency ‘smtpdaemon’:
    error: Failed build dependencies:
    smtpdaemon is needed by php-5.3.3-26.el7.x86_64

    I’m using a centos7 docker image to perform the build, so starting from a clean slate.

  5. Alejandro Fernandez

    Hi! I’m in the same situation so thanks very much for this guide. Some comments:

    1) It should have another hyphen here: rpmbuild –-rebuild php-5.3.29-1.el7.src.rpm
    2) I didn’t have groups set up properly on centos 7 so I had to run “yum install bzip2-devel curl-devel gmp-devel httpd-devel libstdc++-devel openssl-devel sqlite-devel libtool gcc-c++ mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel libicu-devel”
    3) The build failed with “configure: error: mysql configure failed. Please check config.log for more information.”

    Also I’ve now stopped trying this route as it’s possible that with 5.4 which can still work in centos 7 my legacy site will run, and if not, centos 6 is still supported for a few months more, and should have 5.3. All the same thanks for writing up these steps!

  6. didint work for me the last command rpmbuild –rebuild php-5.3.29-1.el7.src.rpm

  7. Hallo ,
    mal eine Anleitung die einiger maßen funktioniert.
    Zwei Hinweis :
    1. Beim Kopieren müssen die Anführungszeichen in gerade geändert werden
    sudo yum -y groupinstall “Development Tools” “Server Platform Development” “Additional Development” “Compatibility libraries”
    2, Der Aufruf
    rpmbuild –rebuild php-5.3.29-1.el7.src.rpm
    muss geändert werden in
    rpmbuild php-5.3.29-1.el7.src.rpm -–rebuild
    Danke und MfG
    KlinkerW

Leave a Reply

Your email address will not be published. Required fields are marked *