PHP Linux installation or php upgrade howto

by on December 12, 2006 · 32 comments· LAST UPDATED December 12, 2006

in , ,

Q. How do I install PHP under Red Hat enterprise Linux?

A. PHP (Hypertext Preprocesso) is a server-side web programming language that you can embed into HTML pages. When a user accesses a PHP-based page, PHP dynamically creates a web page that is then passed to the browser.

PHP works with Apache, Lighttpd and other webservers. PHP offers built-in database integration for several commercial and non-commercial database management systems. It also has the ability to perform many useful Web-related tasks using a large set of built-in functions.

PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output, but command-line scripting and client-side GUI applications are part of the three primary uses of PHP as well. PHP can be deployed on any web server and on almost every OS platform free of charge.

Installing PHP is easy these days.

Red Hat enterprise Linux PHP installation

If you would like to install or upgrade PHP use up2date command:
# up2date php

CentOS/Fedora core Linux PHP installation

If you would like to install PHP use yum command
# yum install php

If you would like to upgrade PHP use yum command
# yum update php

Debian / Ubentu Linux PHP installation

If you would like to install or upgrade PHP use atp-get command
# apt-get install php4-cgi php4-cli
# sudo apt-get install php4-cgi php4-cli

To install PHP 5
# apt-get install php5-cgi php5-cli
# sudo apt-get install php5-cgi php5-cli

FreeBSD PHP installation

Use pkg_add command as follows:
# pkg_add -v -r php

Use above command to install Apache or Lighttpd web server.

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

{ 32 comments… read them below or add one }

1 Mohan June 1, 2007 at 6:43 am

Can you please provide the detailed step by step process for Upgrading the PHP4 to PHP 5.?

Also the system requirements for this like Zend Engine, Apache server version required or MySQL version required ?

Reply

2 nixCraft June 1, 2007 at 9:28 pm

Just run up2dat/yum or apt-get command to update version. If you need more help join our forum

Reply

3 Naresh Khokhaneshiya October 15, 2007 at 1:54 pm

Hello there,
Actually when I run ‘yum update php’ on CentOS 5, it does not update the php to the latest version of 5.2.3 and remains to version 5.1.6 only and says that it can not find any updates.
Anything am I missing?
Regards,
Naresh Khokhaneshiya

Reply

4 nixCraft October 15, 2007 at 6:08 pm

Naresh,

5.1.6 is latest and stable for RHEL / CentOS. PHP 5.2.3 won’t be available for CentOS 5.0. You have to wait or compile from source code.

Reply

5 Mars October 24, 2007 at 10:59 pm

I to in a way have the same problem as Naresh
however a little defferant. I have version 5.1.6
and am trying to install ffmpeg.php it needs the comand phpize to be ran and there is no sush program on my server !
which phpize / it says none
Why would this not get installed with my version of php (any ideas ?) Also if you have any thoughts as to how I can install this please let me no. I realy do not want to have to reinstall php or upgrade.
have you hurd of a patch for this or something?

Thanks Mars

Reply

6 nixCraft October 25, 2007 at 2:20 pm

Mars,

Install php-devel package to get phpize binary:
yum install php-devel

Reply

7 John December 29, 2007 at 8:11 pm

Hi,

Thanks for your guide. I ran the update command using yum and my PHP was updating to a version of Nov 2005. My system is Redhat. Can you tell me how to upgrade to the latest PHP version? Do I have to first uninstall the old version or something?

Thanks

Reply

8 nixCraft December 30, 2007 at 11:43 am

John,

If you are using RHEL 4, there is no offical PHP 5 exists. Redhat only provides updates for RHEL 4. I strongly recommend to update your box to RHEL 5.x

Reply

9 Marlin April 5, 2008 at 3:52 pm

HEllo all
I ran this and it installed the phpize
Install php-devel package to get phpize binary:
yum install php-devel

However now when i try to use phpize it says?
make sure you run ‘usr/bin/phpize’ in the top level source directory of the module

I have looked everywhere on the net and there is no help on this that i could find. Do you have any thoughts on what this means?

Thank You

Reply

10 Photos China May 22, 2008 at 7:37 am

I tryed the command on Ubuntu:
sudo apt-get install php5-cgi php5-cli

Ant it installed the version 5.2.3 of php but the last version is 5.2.6.

It’s not so important, but how upgrade to the last version using apt-get ?

Thanks for this post

Reply

11 Danno October 27, 2008 at 1:50 am

Hey, I have the same questions. How is it easier to get the latest version installed, and not the patches. I ran configure make and make install, and I still get the previous version.

It would be great if apt-get would install php 5.2.6

Reply

12 Bob November 20, 2008 at 12:14 am

I am on Fedora Core 6 and currently on PHP 5.1.6. When I ran “yum update php” it didn’t pick up the new 5.2 version, any ideas?

Reply

13 Jeff December 15, 2008 at 12:29 pm

#yum update php
Setting up Update Process
Setting up repositories
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
centosplus 100% |=========================| 951 B 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Could not find update match for php
No Packages marked for Update/Obsoletion

fail to update..anyone can help?

Reply

14 joe blow April 15, 2009 at 1:10 am

What if you want to update PHP that isn’t supported by the vendor? You would need to either build yourself from source or find a pre-packaged PHP. I’ve encountered this with new bleeding edge applications that want the newest PHP 5.2 or 5.3. How do you integrate those versions of PHP with a currently existing Apache?

Reply

15 Ashwin June 30, 2009 at 11:30 am

To update php-4 to php-5 edit your repositories located in (/etc/yum.repos.d), then open CentOS-Base.repo using your favourite editor find [centosplus] below it you will find enable=0 change it to enable=1 an then run yum update php if have any issue do let me know.

Ashwin Wadhwa

Reply

16 Aaron November 4, 2009 at 3:27 pm

I love how everyone assumes I have yum, or apt-get, or up2date.

I’m trying to upgrade php from bash command line and downloaded .gz packages.

Working on a DoD SECRET network, I will never have cloud connectivity to use these nifty updaters.

/google on

Reply

17 Jerry Ballmer November 16, 2009 at 11:27 pm

“I love how everyone assumes I have yum, or apt-get, or up2date.”

why wouldn’t they? that is the standard setup for most users.

“Working on a DoD SECRET network”

good thing you mentioned this, now we can all think of you in awe and realize how great you must be.

“I’m trying to upgrade php from bash command line and downloaded .gz packages.”

this is really all we needed in addition to letting us know you don’t have net access from your server in question.

HTH

Reply

18 Cripto March 16, 2010 at 11:01 pm

Aaron, glad to know that…
if it was secret, now it isnt anymore.
Congrats for showing the world what you do / dont do.

if you were more attentive, you would see the answer is up.
You can compile from source, or downloadpre-packaged.

Like Jerry said, it is quite common to use apt-get or yum.
yum is Fedora and RH based.
apt-get from Ubuntu and Debian.
Both are standard and well accepted / respected.

but of course,.. if you use a secret operating system and secret software in bash,
you dont need the super common “nifty updaters”. ROTFL

Reply

19 farhad March 29, 2010 at 12:42 pm

I have installed php 5.1.6 manually by rpm .
I am try to upgrade from php-5.1.6 to php 5.2 in redhat 4 (Nahant Update 2)

How can i do it ?

Reply

20 slacker April 27, 2010 at 5:52 pm

This can be done in one of two ways.
1. use yum as this post suggests:
[root@box ~]# yum update php

2 download the rpm (find the uri for the package from php.net and do
[root@box ~]# wget .rpm
[root@box ~]# rpm -Uvh .rpm

Reply

21 slacker April 27, 2010 at 5:48 pm

lame. apt-get, yum, up2date, etc are only wrappers for ‘s package manager. Assuming that ppl can install a distro, setup a repository, only to depend on that distro’s intrinsic utils is, as Aaron pointed out, lame. if nixcraft really wanted to be helpful, a brief reminder on ‘tar -zxvf .tar.gz && cd `ls | grep ` && ./configure && make && make install’ would have been far more beneficial. Don’t think that attitude of “apt-get and yum cover most everyone, so if you don’t have it, get” is going to earn you any cred.

Use the source, Luke

Reply

22 everydaypanos June 24, 2010 at 7:13 pm

Is it me or everyone is kind of trying NOT to answer the question? It’s like: I know how to update PHP but I don’t really care to help anyone else because I spent hours googling and some noob wants it on a plate.

Don’t you just love the Open Source community spirit?

At the end of the day, yum update php is NOT the solution. Because the problem is upgrading to a version of PHP that you actually want…

Reply

23 Andi Herdiana July 5, 2010 at 3:53 am

Please help me!
How to upgrade php and MySQL on FEDORA CORE 4 with detail description!

Thank you before!

Reply

24 Aaron September 15, 2010 at 3:19 pm

Goodness, I wasn’t trying to garner any awe. I was venting because developing on a closed network RHEL server is a major pain in the ass! No repo’s make me cry hard.

I forgot I even made this post haha. I’m faced with more of the same and started looking for a PHP upgrade procedure via BASH landed me back here…

PHP 5.0 on the production server but my dev server is using 5.2 so when I went to stand up a Flex application today the DateTime function bit me.

By the way, the network is still SECRET and will always be regardless if I speak of it or not.

/google on MOAR!

Reply

25 Terry September 28, 2010 at 3:15 pm

You must have a way to download files, if you can get a .gz source file.

For example: at home, find the RPM for the package you want to use, burn it to a CD, take it to work, mount the CD, then use the rpm command to install the package.

If bringing a file from home isn’t permitted, then ask your network admins to get the rpm file for you from the ‘net and copy it to your secret network. Then use rpm to install it.

Reply

26 Dayawansa October 18, 2010 at 9:52 am

I have PHP 5.1 and MYsql 5.0.22. My system is Redhat enterprse server 5. But I am unable to connect the mysql database through PHP.Can you tell me how to upgrade to the latest PHP version from internet at my unix box? Do I have to first uninstall the old version or something

Reply

27 Sanford Dickert November 23, 2010 at 2:42 am

Check the following site for an upgrade path on CentOS 5 at godaddy.

http://wiki.centos.org/HowTos/PHP_5.1_To_5.2

Reply

28 danoprey June 29, 2011 at 9:28 am

Perfect, thank you so much for the guide.

Reply

29 Ganga September 29, 2011 at 11:26 am

Yes. It works perfectly for me..
I am using Centos5.5….

Thanks Sanford….

Reply

30 sapy February 25, 2011 at 11:16 am

Pls run the following command :whereis php
now depending on the mode of installation may be u can try setting the home path of php for updated version.

Reply

31 harfano December 5, 2012 at 3:21 am

i’ve trying Sandford suggestion but it’s not working.i’m using CentOS 5.8 (final) on i386.
is there any other way? please…

Reply

32 prathap February 24, 2014 at 9:27 am

Hi All,

I try to update php 5.1.6 to latest but not able to update. i’m using CentOS-5.10.

[root@srv01 ~]# lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.10 (Final)
Release: 5.10
Codename: Final
[root@srv01 ~]# php –version
PHP 5.1.6 (cli) (built: Dec 10 2013 22:14:51)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
[root@srv01 ~]# yum update php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.dhakacom.com
* base: mirror.dhakacom.com
* epel: buaya.klas.or.id
* extras: mirror.dhakacom.com
* rpmforge: mirror.oscc.org.my
* updates: mirror.dhakacom.com
Setting up Update Process
No Packages marked for Update
[root@srv01 ~]#

Reply

Leave a Comment

Tagged as:

Previous Faq:

Next Faq: