Home Tutorial Install, Upgrade dan Downgrade PHP
formats

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 :-

http://us1.php.net/get/php-5.3.17.tar.gz/from/a/mirror

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 – http://www.atomicorp.com/installers/atomic |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: www2.atomicorp.com
* rpmforge: repoforge.spinellicreations.com

php.i386 5.4.22-28.el5.art 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 :-

php-5.3.16-9.el5.art
php-common-5.3.16-9.el5.art
php-cli-5.3.16-9.el5.art
php-gd-5.3.16-9.el5.art
php-mcrypt-5.3.16-9.el5.art
php-tidy-5.3.16-9.el5.art
php-mssql-5.3.16-9.el5.art
php-mbstring-5.3.16-9.el5.art
php-ldap-5.3.16-9.el5.art
php-pdo-5.3.16-9.el5.art
php-xml-5.3.16-9.el5.art
php-mysql-5.3.16-9.el5.art

> Remove all of the existing php 5.3 packages :-

# yum remove php-5.3.16-9.el5.art
# yum remove php-gd-5.3.16-9.el5.art
# yum remove php-common-5.3.16-9.el5.art ( 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

http://www6.atomicorp.com/channels/atomic/centos/5/i386/RPMS/ ( this link may not get you to much older RPMs )
http://rpmfind.net/linux/rpm2html/search.php (this link might get you much older RPMs)
http://rpm.pbone.net/ (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

php-5.2.5-7.i386.rpm
php-cli-5.2.5-7.i386.rpm
php-common-5.2.5-7.i386.rpm
php-dba-5.2.5-7.i386.rpm
php-devel-5.2.5-7.i386.rpm
php-gd-5.2.5-7.i386.rpm
php-imap-5.2.5-7.i386.rpm
php-ldap-5.2.5-7.i386.rpm
php-mbstring-5.2.5-7.i386.rpm
php-mcrypt-5.2.5-7.i386.rpm
php-mssql-5.2.5-7.i386.rpm
php-mysql-5.2.5-7.i386.rpm
php-pdo-5.2.5-7.i386.rpm
php-tidy-5.2.5-7.i386.rpm
php-xml-5.2.5-7.i386.rpm

or version = 5.2.17-1

php-5.2.17-1.el5.art.i386.rpm
php-cli-5.2.17-1.el5.art.i386.rpm
php-common-5.2.17-1.el5.art.i386.rpm
php-dba-5.2.17-1.el5.art.i386.rpm
php-devel-5.2.17-1.el5.art.i386.rpm
php-gd-5.2.17-1.el5.art.i386.rpm
php-imap-5.2.17-1.el5.art.i386.rpm
php-ldap-5.2.17-1.el5.art.i386.rpm
php-mbstring-5.2.17-1.el5.art.i386.rpm
php-mcrypt-5.2.17-1.el5.art.i386.rpm
php-mssql-5.2.17-1.el5.art.i386.rpm
php-mysql-5.2.17-1.el5.art.i386.rpm
php-pdo-5.2.17-1.el5.art.i386.rpm
php-tidy-5.2.17-1.el5.art.i386.rpm
php-xml-5.2.17-1.el5.art.i386.rpm

> 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
gpgcheck=0
# 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 php-5.2.17-1.el5.art

– this will automatically install = php-cli-5.2.17-1.el5.art , php-common-5.2.17-1.el5.art

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

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

# yum install php-mssql-5.2.17-1.el5.art.i386.rpm
# yum install php-mysql-5.2.17-1.el5.art.i386.rpm

———————————–

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 : https://docs.comp.nus.edu.sg/node/4119

Tags: ,

Leave a Reply

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