PHP Linux installation or php upgrade howto

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.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 15 comments… read them below or add one }

1 Mohan 06.01.07 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 ?

2 nixcraft 06.01.07 at 9:28 pm

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

3 Naresh Khokhaneshiya 10.15.07 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

4 vivek 10.15.07 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.

5 Mars 10.24.07 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

6 vivek 10.25.07 at 2:20 pm

Mars,

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

7 John 12.29.07 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

8 vivek 12.30.07 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

9 Marlin 04.05.08 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

10 Photos China 05.22.08 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

11 Danno 10.27.08 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

12 Bob 11.20.08 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?

13 Jeff 12.15.08 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?

14 joe blow 04.15.09 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?

15 Ashwin 06.30.09 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

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Change vsftpd ftp server port 21

Next post: Linux, UNIX set the time zone on a per user basis