Blog Hosting, Server, Linux, Jaringan Komputer dan Internet 

Home Tutorial Install, Upgrade dan Downgrade PHP

Install, Upgrade dan Downgrade PHP

Published on November 23, 2014, by in Tutorial.

Installing/ Upgrading/ Downgrading PhP version
Installing PhP

1) Installing PhP via yum RPM Packages

First time installing php on your server = refer to “Installing PhP together with mysql”

2) Installing PhP via Source (w/o yum )

Download the “tar.gz” file from :-

Extract to a folder (in your linux host)

# ./configure

# make

# make install

– the problem with installing via source – is that our VM is not installed with the gcc compiler and other stuffs – that are needed for installation from source to be successful.
– you will have to find out how to install those other stuffs before you can install php via source.

Therefore, we suggest installing via yum instead.


Upgrading PhP

Check your php version

# yum info php

Look at the installed packages= eg. Version: 5.3.16-9

Upgrade PhP ver 5.3 to the latest version

Download and install the atomic.repo file located in = /etc/yum.repos.d.

# cd /etc/yum.repos.d

# wget -q -O – |sh

Check the available latest php version from atomic repo server :

# yum check-update php

-> you will see eg. :-

Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
* atomic:
* rpmforge:

php.i386 atomic

-> which means that the latest version is = 5.4.22-28

# yum update php
# yum update php php-* mysql-*
=> yum upgrade all available installed php and mysql packages to the latest version – getting them from the atomic repo server.

If you want to install additional packages :-
# yum install php-mcrypt php-mhash php-mssql php-tidy
=> this is installing php packages = “php-mcrypt”, “php-mhash”, “php-mssql”, “php-tidy” – of the latest version – getting them from the atomic repo server

# /etc/init.d/httpd restart

Check that all your php packages are of the latest version = # rpm -qa | grep php


Downgrading PhP

# yum downgrade php*

– repeat the process again if you want to downgrade further.

If you are unable to downgrade further using the above method :

Example -> by doing the above method, the oldest PhP version that you get is = 5.3.16-9

Let say you want to install PhP ver 5.2.5-7 , but currently you have PhP version 5.3.16-9

Firstly, you want yum to stop updating php with the latest version :-

-> vi /etc/yum.repos.d/atomic.repo
add this line (after the last line)= exclude=php*

exclude php and kernel packages during yum update

vi /etc/yum.conf

Append the following line under [main] section, enter:
exclude=php* kernel*


> Check/List existing (installed) php packages :-

# rpm -qa | grep php

eg. you get :-

> Remove all of the existing php 5.3 packages :-

# yum remove
# yum remove
# yum remove ( this will automatically remove several other pkgs too )

and so on .. remove everything

# service httpd restart

# yum info php ( you should get nothing – no php )

– or check via your web browser = /phpinfo.php

> Download php packages ( this link may not get you to much older RPMs ) (this link might get you much older RPMs) (you can also try searching here eg. search for = php-cli-5.2.5-7.i386.rpm )

-> You are looking for php packages of version = 5.2.5-7
-> look for i386 (32bit) , CentOs 5.10 ( -check your CentOS version)

eg. version 5.2.5-7


or version = 5.2.17-1

> Upload to /etc/yum.repos.d/

> Start installing the older PhP

# cd /etc/yum.repos.d/

— example with version 5.2.5-7 :-

# yum install php-common-5.2.5-7.i386.rpm
# yum install php-cli-5.2.5-7.i386.rpm
# yum install php-5.2.5-7.i386.rpm

.. and so on with lastly :-

# php-mssql-5.2.5-7.i386.rpm
# php-mysql-5.2.5-7.i386.rpm

> If there is problem installing any one of the package
eg. — missing dependancy (it will show which rpm is needed) = install the needed package first, and try installing the problem package again.
eg. — if there are other errors -> try # yum clean all, # service httpd restart, and install that package again
eg. — It reports rpm not signed -> you will need to disable the “sign” checks at = /etc/yum.conf
# vi /etc/yum.conf
# service httpd restart
-> try installing again
( just for your info = there is also a gpgcheck=1 at /etc/yum.repos.d/atomic.repo )

— example with version 5.2.17-1 :-

# yum install

– this will automatically install = ,

– continue installing the rest ( the same as mentioned above )

.. and lastly (these two must be installed last) :-

# yum install
# yum install


Restart apache = # service httpd restart

# yum info php

You should see installed php Version: 5.2.5-7 ( or 5.2.17-1 )

# service mysqld restart

Go to web browser, check = /phpinfo.php


More commands:-

List missing dependant rpm files ( once you know them, you can then install them using yum )

# yum install yum-utils ( to get the utility package-cleanup )

# package-cleanup –problems


dikutip dari :

Tags: ,

Leave a Reply

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