Monday, March 10, 2008

Purpose of this blog: Post things that I learned today! Before I forget it!!

Upgrading to PHP5. I am a java person myself, so even though I understand the concepts behind PHP, its configuration is new to me. I had to upgrade PHP4 to PHP5 on a CentOS 4.x machine! Compiling your own apache and php would work, but is not elegant :-) The first part of the solution was found by Mike (http://mgnetuk.wordpress.com/2007/02/08/upgrading-php4-to-php5-on-centos-the-smooth-way/).

Part1: Finding RPMs that would upgrade just php (all credit goes to Mike for this part)
The RPM gold mine is at http://mirrors.easynews.com/linux/centos/4.6/centosplus/i386 .
You can do this by just setting "enabled" to 1 in the "[centosplus]" section in file
/etc/yum.repos.d/CentOS-Base.repo . Then run "yum update php*". If this does not work,
just change the baseurl under [updates] in /etc/yum.conf to
http://mirrors.easynews.com/linux/centos/4.6/centosplus/i386. Make a copy of yum.conf
and switch back if needed. Try "yum update php*" now.

Part2: Debugging and Enabling the php extensions. Looks like php has this great tool phpinfo()
builtin! To use it. Create a simple php page with just this command. The page would look like:
phpinfo();
?>
Php will create a nice formatted page for you with all the options. You could use this page to
double check the location of php.ini. This page provides all info about loaded modules. If you
see all modules you need you are done. If not, check the location of extension_dir. The
specified directory should contain extension modules. When I did this check, the location said
/usr/lib/php4, but this directory had nothing! The modules were under
/usr/lib/php/modules. Change this location in php.ini and restart apache. Refresh your
phpinfo page to show new status. If your modules were loaded right you would probably see
a section for each extension module. Enjoy :-)