PHP Linux installation or php upgrade howto

by Vivek Gite on December 12, 2006 · 28 comments

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.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 28 comments… read them below or add one }

1 Mohan June 1, 2007

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

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

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 vivek October 15, 2007

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

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 vivek October 25, 2007

Mars,

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

Reply

7 John December 29, 2007

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 vivek December 30, 2007

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

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

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

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

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

#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

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

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

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

“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

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

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 everydaypanos June 24, 2010

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

21 Andi Herdiana July 5, 2010

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

Thank you before!

Reply

22 Aaron September 15, 2010

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

23 Terry September 28, 2010

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

24 Dayawansa October 18, 2010

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

25 Sanford Dickert November 23, 2010

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

26 danoprey June 29, 2011

Perfect, thank you so much for the guide.

Reply

27 Ganga September 29, 2011

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

Thanks Sanford….

Reply

28 sapy February 25, 2011

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

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 7 + 2 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the simple math so we know that you are a human and not a script.



Previous post:

Next post: