Friday, April 1, 2011

How to upgrade PHP 5.1 to PHP 5.2 CENTOS

This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:
# rpm -qa |grep php

 php-common-5.1.6-15.el5.i386
 php-cli-5.1.6-15.el5.i386
 php-5.1.6-15.el5.i386
 php-pdo-5.1.6-15.el5.i386
 php-bcmath-5.1.6-15.el5.i386
 php-ldap-5.1.6-15.el5.i386
 php-devel-5.1.6-15.el5.i386
 php-gd-5.1.6-15.el5.i386
 php-xml-5.1.6-15.el5.i386
 php-mbstring-5.1.6-15.el5.i386
 php-mysql-5.1.6-15.el5.i386
 php-dba-5.1.6-15.el5.i386
As long as you're using the standard PHP packages on your CentOS server you won't need to do anything extra. If you're using extra PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find updated versions of them.

Add the development repositories

First thing we need to do is add the development repositories to yum. When we add the development repository we're going to configure it so it only pulls PHP packages. To start we'll need create a new yum repository configuration file (use your favorite editor):
 # /etc/yum.repos.d/CentOS-Testing.repo
Copy/paste the following into this file:
  # CentOS-Testing:
  # !!!! CAUTION !!!!
  # This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
  # They may or may not replace core CentOS packages, and are not guaranteed to function properly.
  # These packages build and install, but are waiting for feedback from testers as to
  # functionality and stability. Packages in this repository will come and go during the
  # development period, so it should not be left enabled or used on production systems without due
  # consideration.
  [c5-testing]
  name=CentOS-5 Testing
  baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
  enabled=1
  gpgcheck=1
  gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
  includepkgs=php*
Make sure to remove any spaces at the start of each line, then save and close the file and you're done.

Update PHP packages

Before updating your PHP packages you'll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:
 # rpm -qa |grep php
Now you can use yum to update the PHP packages on your system:
 # yum update
You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.2.x. If that is acceptable type "y" to continue and let yum update the packages.
Once yum has completed restart Apache:
 # service httpd restart
To verify the update is working create a simple testing.php in your www directory with the following source code:
<?php
  phpinfo();
?>
and open it in a web browser. The new PHP version should be reflected at the top of the page.

Conclusion

You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.
 # rpm -qa |grep php

  php-cli-5.2.6-2.el5s2
  php-mbstring-5.2.6-2.el5s2
  php-devel-5.2.6-2.el5s2
  php-pdo-5.2.6-2.el5s2
  php-gd-5.2.6-2.el5s2
  php-dba-5.2.6-2.el5s2
  php-common-5.2.6-2.el5s2
  php-bcmath-5.2.6-2.el5s2
  php-xml-5.2.6-2.el5s2
  php-pear-1.5.1-2.el5s2
  php-ldap-5.2.6-2.el5s2
  php-5.2.6-2.el5s2
  php-mysql-5.2.6-2.el5s2


 # php -v

  PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
  Copyright (c) 1997-2008 The PHP Group
  Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

How to install phpmyadmin CENTOS

  1. $ su -
  2. # cd /var/www/html
  3. # wget -c http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.3.10/phpMyAdmin-3.3.10-english.tar.gz/download
  4. # tar xvzf phpMyAdmin-3.3.10-english.tar.gz
  5. # mv phpMyAdmin-3.3.10-english phpmyadmin
  6. # cd phpmyadmin
  7. # cp config.sample.inc.php config.inc.php
  8. # vi config.inc.php
    :
    $cfg['Servers'][$i]['auth_type'] = ‘http‘; # default is cookies
    :
  9. # service httpd restart
You can test by open phpmyadmin by this link :
http://your.domain.com/phpmyadmin/
You should be find pop up for insert your user name and password

How to Recover MySQL Database root password ( CENTOS, DEBIAN )

#/etc/init.d/mysql stop
or
#/etc/init.d/mysqld stop

Now you need to Start MySQL server without password

# mysqld_safe --skip-grant-tables &

Connect to mysql server using mysql client with the following command

# mysql -u root

Now you should be having mysql prompt

mysql>
Now you need to Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where user=’root’;
mysql> flush privileges;
mysql> quit

Note: Replace newrootpassword with the new root password for MySQL server. Flush Privileges is needed to making the password change effect immediately.
Now you need to Stop MySQL Server using the following command

# /etc/init.d/mysql stop
or
# /etc/init.d/mysqld stop

Test Your New Mysql root password
First you need to start mysql server using the following command

# /etc/init.d/mysql start

# mysql -u root -p

Now it will prompt for root password and enter your new root password