Install PHP 5 on Red Hat Enterprise Linux version 4

by on October 18, 2006 · 54 comments· LAST UPDATED November 16, 2013

in , ,

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 http://www.cyberciti.biz/files/lighttpd/rhel4-php5-fastcgi/php-5.1.4-1.esp1.src.rpm
# 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 ;)

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 54 comments… read them below or add one }

1 Jason October 20, 2006 at 3:48 am

Or, you could grab the src rpm from FC5, which builds cleanly on RHEL4. (http://redhat.download.fedoraproject.org/pub/fedora/linux/core/5/source/SRPMS/php-5.1.2-5.src.rpm)

Reply

2 Jason October 20, 2006 at 3:49 am

Or, you could just grab the src rpm from FC5, which compiles cleanly on RHEL4.

Reply

3 nixCraft October 20, 2006 at 6:48 am

Jason,

Good finding. I never mixed up FC with RHEL. But I guess SRC RPM makes the difference.

I think you can also use SRC RPM from CentOS project.

Appreciate your post.

Reply

4 debbie taylor October 25, 2006 at 5:52 pm

tell me how to put windows 2000 on my computer red hat fedora either 4 or 6

Reply

5 nixCraft October 26, 2006 at 2:43 pm

Assuming that you have 40 GB hard disk
Create one partition and Install Windows 2000 in 10GB first
Next install linux and create 2 partition
Ext3 for 10GB
Swap 512MB
Install MBR on first partition and let the grub boot both oses.

Reply

6 James December 5, 2006 at 6:08 am

checking for mSQL 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 UNIX socket location… no
checking for mysql_close in -lmysqlclient… yes
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.5476 (%build)

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

I updated to mysql5 RPMs from the mysql site. not sure how ti fix this. ideas?

Reply

7 nixCraft December 5, 2006 at 6:21 am

James,

What versions of OS, MySQL server, libmysqlclient and PHP do you use?

Reply

8 neo_yorke December 28, 2006 at 9:45 am

You need MySQL-devel-standard-XX (your distro)

Reply

9 Raykin January 21, 2007 at 8:43 pm

I’m just did a fresh install of Redhat Enterprise V4 along with Apache 2 and mySQL that came with the install. I purposely did not install any PHP as the version that comes with the package is version 4. (I need to install version 5).

I understand these instructions up to Step 3…”Go to /usr/src/redhat/RPMS directory and install PHP5 RPM files.”

How do you “install”? Do you mean copy them into the directory?

Reply

10 nixCraft January 22, 2007 at 3:13 pm

Use rpm command to install:
cd /usr/src/redhat/RPMS
rpm -ivh file.rpm

Reply

11 habitnoir February 17, 2007 at 4:50 am

I am trying to build php5.1.2 from fc5 source but I keep running into a compiler error concerning the flag “-Wno-pointer-sign”. Is it necessary? I have RHEL v4. I updated gcc to 3.4.6 in an attempt to fix the problem. I’ve included an excerpt of the config.log below.

Thanks.

==begin

configure:2547: gcc -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -fno-strict-aliasing -Wno-pointer-sign conftest.c >&5
cc1: error: unrecognized command line option “-Wno-pointer-sign”
configure:2550: $? = 1
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME “”
| #define PACKAGE_TARNAME “”
| #define PACKAGE_VERSION “”
| #define PACKAGE_STRING “”
| #define PACKAGE_BUGREPORT “”
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2589: error: C compiler cannot create executables

==end

Reply

12 Lorenzo March 10, 2007 at 7:59 pm

Got the same issue! Sigh!

Reply

13 squeegee March 13, 2007 at 10:19 am

You need to compile with gcc 4.x.x, not 3.x.x

Reply

14 Emilio March 22, 2007 at 10:37 am

rpm -ivh php-5.1.4-1.esp1.src.rpm
1:php ########################################### [100%]

Please, I need your help.What I have to do now?
I have a RHEL4 and PHP 4.3.9 is running… I want to upgrade it to v.5. After step #3 what I have to do?

Reply

15 nixCraft March 22, 2007 at 11:38 am

Type following commands:
cd /usr/src/redhat/SPECS
rpmbuild -bb php.spec
cd /usr/src/redhat/RPMS
rpm -Uvh php*

Reply

16 Emilio March 22, 2007 at 11:48 am

Thank you nixcraft for your reply, this is what it returned:

# rpmbuild -bb php.spec
cat: /usr/include/httpd/.mmn: No such file or directory
error: Failed build dependencies:
bzip2-devel is needed by php-5.1.4-1.esp1.x86_64
curl-devel >= 7.9 is needed by php-5.1.4-1.esp1.x86_64
expat-devel is needed by php-5.1.4-1.esp1.x86_64
gmp-devel is needed by php-5.1.4-1.esp1.x86_64
aspell-devel >= 0.50.0 is needed by php-5.1.4-1.esp1.x86_64
httpd-devel >= 2.0.46-1 is needed by php-5.1.4-1.esp1.x86_64
libjpeg-devel is needed by php-5.1.4-1.esp1.x86_64
libpng-devel is needed by php-5.1.4-1.esp1.x86_64
pcre-devel >= 4.5 is needed by php-5.1.4-1.esp1.x86_64
libc-client-devel is needed by php-5.1.4-1.esp1.x86_64
net-snmp-devel is needed by php-5.1.4-1.esp1.x86_64

Oh my god…

Reply

17 nixCraft March 22, 2007 at 11:57 am

Install all those deps using up2date command –
up2date bzip2-devel aspell-devel .... etc-all

Reply

18 emmy March 30, 2007 at 5:08 pm

Is there no direct rpm package for php on RHEL4 that will not require an building.

When i attempted building the php.spec file i get
error: Failed build dependencies:
aspell-devel >= 0.50.0 is needed by php-5.1.4-1.el4s1.2.i386
httpd-devel >= 2.0.46-1 is needed by php-5.1.4-1.el4s1.2.i386
pcre-devel >= 4.5 is needed by php-5.1.4-1.el4s1.2.i386
libc-client-devel is needed by php-5.1.4-1.el4s1.2.i386
postgresql-devel is needed by php-5.1.4-1.el4s1.2.i386
unixODBC-devel is needed by php-5.1.4-1.el4s1.2.i386
net-snmp-devel is needed by php-5.1.4-1.el4s1.2.i386

i presume will ask me to use up2date to get this packages. Unfortunately I cannot seem to use up2date becase i dont have serials on my Redhat edition.

is there any other way please

Reply

19 nixCraft March 30, 2007 at 5:23 pm

emmy,

Install rpms from CD/media using rpm command. You need to mount a cd first and locate package.

Reply

20 rev_aaron April 20, 2007 at 10:06 pm

error: Failed build dependencies:
aspell-devel >= 0.50.0 is needed by php-5.1.2-5.i386
httpd-devel >= 2.0.46-1 is needed by php-5.1.2-5.i386
libjpeg-devel is needed by php-5.1.2-5.i386
libpng-devel is needed by php-5.1.2-5.i386
sqlite-devel >= 3.0.0 is needed by php-5.1.2-5.i386
pcre-devel >= 4.5 is needed by php-5.1.2-5.i386
libtool >= 1.4.3 is needed by php-5.1.2-5.i386
libc-client-devel is needed by php-5.1.2-5.i386
mysql-devel >= 4.1.0 is needed by php-5.1.2-5.i386
postgresql-devel is needed by php-5.1.2-5.i386
unixODBC-devel is needed by php-5.1.2-5.i386
net-snmp-devel is needed by php-5.1.2-5.i386
libxslt-devel >= 1.0.18-1 is needed by php-5.1.2-5.i386
gd-devel is needed by php-5.1.2-5.i386
freetype-devel is needed by php-5.1.2-5.i386

Reply

21 rhil May 2, 2007 at 3:55 pm

If you have php4 installed in your system already its better to uninstall it along with all the dependency. or when you try to install with rpm force it to install and use –no-deps so it will not check the dependency

Reply

22 alex May 16, 2007 at 9:13 am

If I install using Step 1, do I still need to do Step 2 and Step 3?

I am using RHEL 4.

Thanks.

Reply

23 alex May 16, 2007 at 9:28 am

Hi,

I am using PuTTy to remotely install using root and I am on step 2, rebuilding rpm. Unfortunately my internet connection was disconnected.

By theory, what I see here is only what is being done in the server. Will my rebuilt stopped and I need to redo it? Or it may already finished? How do I check that?

Regards,
Alex

Reply

24 nixCraft May 16, 2007 at 9:37 am

Alex,

You need to rebuild all rpms using rpmbuild command if ssh terminated. 1st step will only install src rpm you need to complete rest of the all.

HTH

Reply

25 Cesar June 4, 2007 at 3:24 pm

Hello I can get to the final step just fine, but when I got to install php i receive this error.

error: open of php-pear-4.3.9-3.22.4.i386.rpm failed: No such file or directory
error: Failed dependencies:
php-pear is needed by php-5.1.4-1.esp1.i386

When I down this package and put it in the same directory as the other rpms it still gives the same error even though i have the –aid option set when trying to install. Any suggestions?

Reply

26 miller June 21, 2007 at 4:09 pm

I get the same error last posted.

error: open of php-pear-4.3.9-3.22.4.i386.rpm failed: No such file or directory
error: Failed dependencies:
php-pear is needed by php-5.1.4-1.esp1.i386

Any solution

Reply

27 Jonas July 12, 2007 at 7:50 pm

Cesar and Miller,

this problem is easy of if to decide, is enough to lower php-pear.

Package: php-pear-1.4.9-1.2.noarch. It makes download:

# wget http://hosting.xoxidemods.com/rpms/php-pear-1.4.9-1.2.noarch.rpm

Reply

28 JJP July 20, 2007 at 3:25 pm

Question,

I am trying this method of installing PHP5 on our RHEL 4 dev box, and wanted to know if you, nixcraft, or anyone else who gotten this to work is available to assist with this matter.

I am getting the dependencies error and have found that up2date did not, in fact, bring the dependencies up-to-date enough for the reubilt rpm to work.

Thanks In Advance

–JJP

Reply

29 Ratana Ty August 16, 2007 at 6:24 pm

Hi All,

I can solve most of the problem by mounting
the CD then trying to install it, but what I notified is those package is not available from CD1 to CD4, Do any one have any idea about what/how can I move on…
# rpmbuild -bb php.spec
=======================
cat: /usr/include/httpd/.mmn: No such file or directory
error: Failed build dependencies: httpd-devel >= 2.0.46-1 is needed by php-5.1.4-1.esp1.i386
libc-client-devel is needed by php-5.1.4-1.esp1.i386
postgresql-devel is needed by php-5.1.4-1.esp1.i386
net-snmp-devel is needed by php-5.1.4-1.esp1.i386
=======================

Thanks,

Ratana

Reply

30 Amanda Gillespie December 21, 2007 at 2:38 pm

Sheesh, this is why people think Linux is hard (including me). I’ve been dumped into a Sysadmin position with virtually no experience (I know — don’t even go there!). We are running RHEL 3 (and no, it can’t be updated for some reason).

I’ve been trying to install PHP 5 (currently have PHP4) so I can get Apache2 to run 4 and 5 concurrently. I can’t delete PHP 4 because some apps require it, and I need PHP 5 for some other apps.

I can’t get up2date to work – something about all the registration channels being full.

I tried the steps above and got a whole bunch of dependency failures… so now what? (This whole thing has me close to tears!)

Reply

31 nixCraft December 21, 2007 at 4:03 pm

Amanda,

Upgrade your Linux distro to RHEL 5, as support for PHP4 is dead (deadline is 31, Dec – 2007). After that no one will support or update php 4. This is how to only tested on RHEL 4 and it is not supported by Red hat. Tell you developers / users that they must upgrade application to php 5.

Hope this helps.

Reply

32 Mike January 8, 2008 at 7:55 pm

When I compile I get an error, I’am using RHEL 4

D/php-5.1.4/TSRM -I/usr/src/redhat/BUILD/php-5.1.4/build-cgi/ -I/usr/include -O2 -g -pipe -m64 -o ext/ldap/ldap.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/src/redhat/BUILD/php-5.1.4/build-cgi/modules -L/usr/kerberos/lib -L/usr/kerberos/lib64 ext/ldap/ldap.lo -lldap -llber
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/libc-client.a(osdep.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/libc-client.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [ext/imap/imap.la] Error 1
make: *** Waiting for unfinished jobs….
error: Bad exit status from /var/tmp/rpm-tmp.90947 (%build)

I also tried to us FC6 as suggested above but had a depency problem on something called sqlite-devel
which I think doesn’t exist on RHEL

Reply

33 Dave January 10, 2008 at 11:50 pm

Where can I can find which version of Redhat support what versions of PHP? Is there a roadmap?

Reply

34 IA64 PHP5 FOR RHEL4 January 22, 2008 at 9:05 am

I want to installed php-5 ia64 bit on RHEL4.please send me a php5 rpm.ia64

Reply

35 INF[SZ] June 5, 2008 at 3:45 pm

Enable centosplus repo for install php 5 on RHEL 4

Link: to download php5 for RHEL4 /CentOS 4

Reply

36 AK BORA July 9, 2008 at 5:14 pm

How RHEL 4 is more effective than linux version 8.0?

Reply

37 Vasyl July 11, 2008 at 11:02 am

I have same problems like Mike:
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/libc-client.a(osdep.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/libc-client.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [ext/imap/imap.la] Error 1
make: *** Waiting for unfinished jobs….

Mike, what I have to do now?

Reply

38 Vasyl July 15, 2008 at 6:11 am

It is Ok. Problems was in my libc-client.
Tanck`s.

Reply

39 Stanley David July 30, 2008 at 8:23 am

Hi guys, i’ve found this site which having lots of RPMs for EL4. (php5, mysql5, etc)

http://rpms.famillecollet.com/el4.i386/

Hope this will help you all.

Reply

40 tanweernoor November 18, 2008 at 5:19 pm

Hello Nixcraft and senior members
I am looking to install php-5.2.6, could you please point me to procedure and rpms.

thanks
tanweer

Reply

41 palash November 21, 2008 at 11:28 am

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)

Reply

42 Mark February 3, 2009 at 8:49 pm

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

Reply

43 Viz February 9, 2009 at 8:00 pm

You might want to try using the PHP RPM’s created by Oracle at http://oss.oracle.com/projects/php/

Reply

44 Ray February 11, 2009 at 12:45 am

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?

Reply

45 mike February 20, 2009 at 4:30 pm

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 ?

Reply

46 Chirag February 24, 2009 at 12:07 pm


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.

Reply

47 schenelle April 6, 2009 at 10:40 pm

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?
S

Reply

48 Puneet April 7, 2009 at 8:53 am

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.

Reply

49 Erwin May 28, 2009 at 11:46 pm

I need to upgrade my php 5.1.6 to 5.2.9 please help

Reply

50 jormarcha October 29, 2009 at 10:58 am

hi,
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

Reply

51 Nazeer January 14, 2010 at 5:07 am

HI,

Where will I get these dependency files?

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

Thanks in advace

Reply

52 Christen Kowalik March 19, 2010 at 2:53 am

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

Reply

53 zx5000 June 15, 2011 at 3:12 pm

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

Reply

54 wahyoe December 13, 2011 at 6:59 am

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/domxml.so’ – /usr/lib64/php/modules/domxml.so: cannot open shared object file : No such file or directory in Unknown on line 0

can give me advise

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous post:

Next post: