Help In Linux

Linux Technical Blog
February 21, 2011

Steps to upgrade PHP to 5.3.5 and MySQL to 5.1 in CentOS and RHEL


The following steps will make you to upgrade PHP to 5.3.5 using remi repostries in CentOS and RHEL systems.

Preinstallation steps
Make a note of current PHP and MySQL versions by using the following commands
#php -v

#mysql –version

backup running MySQL databases by using the fllowing steps
#cp -arp /var/lib/mysql /var/lib/mysql.bak

then dump the mysql databases using the following command
#mysqldump -you root -p(password) –all-databases > dumpfilename.sql

You can also take version compatible downgrade dump to check for any missing file restoring by using the following command
#mysqldump -you root -p(password) –all-databases –compatible=mysql40 > versioncompatibledumpfilename.sql

Also backup your php.ini(PHP configuration) file

#cp -arp /etc/php.ini /etc/php.ini.back
Upgrading PHP

Downloading Remi rpm

The below command will download and install remi rpms from source.
#rpm -Uvh


Downloading epel rpm

The below command will download and install epel-release rpms from source.


#rpm -Uvh


Remove all old PHP rpms from yum by using the following command.
#yum remove php*

Now you are ready with the remi repostries installed with in the server to upgrade PHP.

Please provide the following command to install php and its modules from yum remi repostries.
#yum –enablerepo=remi install php php-common php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml php-imap php-devel php-odbc php-bcmath php-ldap

After installing restart httpd services

#/etc/init.d/httpd restart
Now you will
You may get errors if your php cannot combine with lower versions of MySQL. So, you need to upgrade MySQL to 5.1

Please remove the older version of MySQL by removing mysql rpms
#yum remove MySQL

Now please install MySQL through remi rpms by following steps
#yum –enablerepo=remi install mysql mysql-server mysql-connector-odbc

The above command will install MySQL 5.1

To start mysql automatically on server restart please provide the following line which will start mysql on run levels 2, 3 and 5
#chkconfig –levels 235 mysqld on

Thats all now you have upgraded PHP and MySQL in the server to 5.3.5 and 5.1 respectively.

Check them by using the following commands
#php -v
#mysql –version

Please let me know if I have made errors, your comments corrects my mistakes.

Thank you for visiting,

Leave a Comment

Protected by WP Anti Spam