Install PHP 5 on Red Hat Enterprise Linux version 4

It appears that many people or sys admin want to run php 5 on Red Hat Enterprise Linux. Unfortunately Redhat does not provide this package (RPM file) for RHEL. You can download source code and install php 5 from official php site. This requires compiler collection on your system. Download source code and just follow instructions presented in INSTALL or REDME file.

Another option is search and installs PHP 5 packages. You can download x86_64 PHP 5 package here. Use wget command to download these packages and rpm command to install new packages. But first remove old php4 package using rpm -e command.

Alert: This post is outdated. Please use the latest version of RHEL/CentOS v6.x+ for PHP 5.x. The author no longer support php 5 rpm on RHEL 4.x.

However these rpm packages 64 bit so if you are running 32 bit os rebuild RPM file.

Step # 1: Download src rpm

# cd /tmp
# wget
# rpm -ivh php-5.1.4-1.esp1.src.rpm

Step #2: Rebuild RPM for 32 bit RHEL version

# cd /usr/src/redhat/SPECS
# rpmbuild -bb php.spec

It will take some time to compile and rebuild RPM files.

Step #3: Install new php5 RPM file

Remove old php4 rpm. Go to /usr/src/redhat/RPMS directory and install PHP5 RPM files.

Please note that PHP 5 is not official supported by Red Hat on RHEL 4.0. You are using these packages on your own risk 😉

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
54 comments… add one
  • wahyoe Dec 13, 2011 @ 6:59

    Hii, i wanna ask
    im using RHEL 4 and had installed PHP5 using this tutorial

    but when i’m using command php -v

    there are error looking like this

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/’ – /usr/lib64/php/modules/ cannot open shared object file : No such file or directory in Unknown on line 0

    can give me advise

  • zx5000 Jun 15, 2011 @ 15:12

    This article is so outdated it should be removed from the web. ALL the links are broken.

  • Christen Kowalik Mar 19, 2010 @ 2:53

    At last a program that gets me access to sky abroad!

  • Nazeer Jan 14, 2010 @ 5:07


    Where will I get these dependency files?

    up2date bzip2-devel aspell-devel …. etc-all

    Thanks in advace

  • jormarcha Oct 29, 2009 @ 10:58

    sorry, where did you find that php5 is not supported in RHEL4.0???
    could you pass me the link?
    I need to convince my team of developers that is not suitable migration

    thanks in advance and sorry about my English

  • Erwin May 28, 2009 @ 23:46

    I need to upgrade my php 5.1.6 to 5.2.9 please help

  • Puneet Apr 7, 2009 @ 8:53

    Hmm, seems this method still expects me to remove php4.

    Can’t I keep both php4 & php5 on the box ? without having to compile php5 from source.

  • schenelle Apr 6, 2009 @ 22:40

    Hi Chirag,
    I did a rpm -e for each packages.
    Then I ran an rpm -e –nodeps for packages that depend on one another (eg for php-pear and php).
    Just out of curiosity Is there a better way to do this?

  • Chirag Feb 24, 2009 @ 12:07

    rpm -Uvh php-5.1.4-1.esp1.i386.rpm
    error: Failed dependencies:
    php = 4.3.9-3.22.12 is needed by (installed) php-devel-4.3.9-3.22.12.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-imap-4.3.9-3.22.12.i386
    php <= 4.4.0 is needed by (installed) php-sqlite2-1.0.2-200608291859.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-pear-4.3.9-3.22.12.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-mysql-4.3.9-3.22.12.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-mbstring-4.3.9-3.22.12.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-gd-4.3.9-3.22.12.i386
    php = 4.3.9-3.22.12 is needed by (installed) php-domxml-4.3.9-3.22.12.i386

    How do I remove the old php 4? I think that’s the problem for me.

  • mike Feb 20, 2009 @ 16:30

    All the steps went okie but php test is fail 🙁

    Some of the bugs:

    Bug #27908 (default handler not being called) [ext/xml/tests/bug27908.phpt]
    Bug #26614 (CDATA sections skipped on line count) [ext/xml/tests/bug26614_libxml.phpt]

    Is it usual ?

  • Ray Feb 11, 2009 @ 0:45

    Hi all
    I managed to install the packages from the FTP site on a RHEL4 64 bit system, without rebuilding the RPMS.
    Works well thanks.
    The people doing our web development have now advised that they require mssql support to work I have installed freetds on the server.
    How do I get PHP support for MSSQL working.
    Is there another module?

  • Viz Feb 9, 2009 @ 20:00

    You might want to try using the PHP RPM’s created by Oracle at

  • Mark Feb 3, 2009 @ 20:49

    I not the greatest at this yet, but I was following the instruction to install PHP and ran across these errors. What I am missing?

    httpd-devel >= 2.0.46-1 is needed by php-5.1.4-1.esp1
    libjpeg-devel is needed by php-5.1.4-1.esp1
    libpng-devel is needed by php-5.1.4-1.esp1
    pcre-devel >= 4.5 is needed by php-5.1.4-1.esp1
    file >= 4.0 is needed by php-5.1.4-1.esp1
    libc-client-devel is needed by php-5.1.4-1.esp1
    mysql-devel >= 4.1.0 is needed by php-5.1.4-1.esp1
    unixODBC-devel is needed by php-5.1.4-1.esp1
    libxslt-devel >= 1.0.18-1 is needed by php-5.1.4-1.esp1
    freetype-devel is needed by php-5.1.4-1.esp1

  • palash Nov 21, 2008 @ 11:28

    When installing php-5.1.4-1.esp1.src.rpm got below errors

    Configuring SAPI modules
    checking for AOLserver support… no
    checking for Apache 1.x module support via DSO through APXS… no
    checking for Apache 1.x module support… no
    checking for mod_charset compatibility option… no
    checking for Apache 2.0 filter-module support via DSO through APXS… no
    checking for Apache 2.0 handler-module support via DSO through APXS…

    Sorry, I cannot run apxs. Possible reasons follow:

    1. Perl is not installed
    2. apxs was not found. Try to pass the path using –with-apxs2=/path/to/apxs
    3. Apache was not built using –enable-so (the apxs usage page is displayed)

    The output of /usr/sbin/apxs follows:
    Can’t exec “/usr/bin/apr-config”: No such file or directory at /usr/sbin/apxs line 48.
    Use of uninitialized value in scalar chomp at /usr/sbin/apxs line 53.
    -O2 -g -pipe -m32 -march=i386 -mtune=pentium4
    apxs:Error: /usr/bin/apr-config not found!.
    configure: error: Aborting
    error: Bad exit status from /var/tmp/rpm-tmp.71083 (%build)

    RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.71083 (%build)

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.