Tags

About Me

I'm Rolf Kaiser. I've ridden the wave from 3-guys-in-a-garage, to an acquisition by a big software company, and have built a string of startups since. This blog is a little compendium of tips and tricks so hopefully the next guy doesn't have to reinvent the wheel.

P.S. the tagline is a sailing reference.

Quickie how-to for getting PHP upgraded on CentOS 5

Today I had to get PHP upgraded from 5.1 to 5.2.X on someone else’s server and didn’t have time to screw around. I have a PHP configuration that I’ve used in the past but it frankly can take too long to get set up, if time is of the essence. So here are my “quickie steps” (tested for the current release, 5.2.11 on CentOS 32- and 64-bit). Follow these and you can be running in 20 minutes (if you type fast!):

Download the latest stable PHP build from http://php.net and extract.

# back stuff up, just in case
cp -rv /usr/lib/php/modules /usr/lib/php/modules-bak
cp -v /usr/lib/httpd/modules/libphp5.so /usr/lib/httpd/modules/libphp5.so.bak
# or, if you're on 64-bit:
mv /usr/lib64/php/modules /usr/lib64/php/modules-bak
ln -s /usr/local/lib/20090626/ /usr/lib/php64/modules
cp -v /usr/lib64/httpd/modules/libphp5.so /usr/lib64/httpd/modules/libphp5.so.bak
# the ones after mysql-devel might be optional if you're pressed for time, but they're needed by phpmyadmin etc.
yum install httpd-devel mysql-devel libmcrypt-devel libxml2-devel zlib-devel libmhash curl-devel
# you may need to do the following, if compiling on 64-bit
export LDFLAGS=-L/usr/lib64/mysql
./configure --with-apxs2 --with-mysql=shared --with-mcrypt --enable-mbstring --with-curl --with-zlib
make clean && make install
# if the build fails, you may need to recompile libmcrypt as per http://marc.info/?l=php-install&m=108030891925096&w=2
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
./configure
make clean && make install
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
./configure --disable-posix-threads
make clean && make install
cd libltdl
./configure --enable-ltdl-install
make clean && make install
# now for some reason by default PHP might be looking in /usr/local/lib for the php.ini, so symlink to it
cd /usr/local/lib
ln –s /etc/php.ini

Also add the following to /etc/php.ini (in case it doesn’t know to scan /etc/php.d by default):