/Dev/Zero Linux

Compile php 5.3 on Centos 7 from RPM

Nov
05

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 ideea to share my steps…

This will be a general simple to follow howto on a brand new centos 7.1 machine.

1. install the Epel Repo
sudo rpm -ihv https://centosup.ispsystem.info/repo/SRPMS/php-5.3.29-2.el6.src.rpm

2. install the Centos Development tools.
sudo yum -y install “Development Tools”

3. Download the centos 6 rpm we will use this spec to rebuild.
I personally like to work in the /root directory for rebuilds.
su –
cd /root
rpm -ihv http://rpms.southbridge.ru/rhel6/php-5.3/x86_64/php-5.3.23-1.el6.remi.src.rpm

The rpm will create a rpmbuild directory inside the root folder

4. switch to the RPM SOURCE folder
cd /root/rpmbuild/SOURCES/

5. download the last php release (5.3.29)
wget http://at2.php.net/get/php-5.3.29.tar.bz2/from/this/mirror -O php-5.3.29.tar.bz2

6. Next step we will need to modify the php.spec file and use the latest version to build.
cd /root/rpmbuild/SPECS

With your favorite editor open the files php53.spec

replace/change the following fields.

Version: 5.3.23 with Version: 5.3.29

 

7. Install all the build required packages
yum install bzip2-devel curl-devel db4-devel gmp-devel httpd-devel pam-devel openssl-devel sqlite-devel zlib-devel pcre-devel libedit-devel libtool-ltdl-devel krb5-devel libc-client-devel cyrus-sasl-devel openldap-devel mariadb-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libXpm-devel libjpeg-devel libpng-devel freetype-devel libtidy-devel aspell-devel recode-devel libicu-devel enchant-devel

8. the spec will look for apxs in /usr/sbin/apx and it moved to /usr/bin/apx
just symlink it
ln -s /usr/bin/apxs /usr/sbin/apxs

9. Re-compile php.
rpmbuild -ba /root/rpmbuild/SPECS/php53.spec

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

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

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

Optional Instal php pear

rpm -ihv rpms.southbridge.ru/rhel6/php-5.3/x86_64/php-pear-1.9.4-12.el6.remi.noarch.rpm