Upgrading Apache, MySQL and PHP on RHEL4 the FUN way

UPDATE: You know what? Fuck, double fuck and triple fuck doing that shit by hand. I ended up scrapping all my work, uninstalling practically everything, adding http://www.jasonlitka.com/media/EL4/x86_64/ to my yum repository, and just installing from there.

Worked first fucking time.

I wouldn’t mind spending whole days crawling through dependency hell if I was, say, in prison and had nothing else to do but understand the minutiae of lib-apr.so linking. But I’m not in prison, I’ve got a lot to do, and so being able to install, say, apache 2.2 (the whole reason I started on this mission) in 5 minutes instead of 15 hours is pretty fucking compelling.

I like compiling from source and doing it myself. But trying to manually coax 3 or 4 co-dependent software system to play nicely is just too fucking hard. In the end it was subversion that did it – I fucking could not get it to talk to Apache. Hours of searching, trying what I found – useless, and potentially damaging.

Using 3rd-party RPMs is inherently a matter of trust. But using 3rd party software is also a matter of trust. I trust Apache to not contain hidden rootkits, even though I haven’t personally audited every line of source. In the same way, I trust the RPMs of the above repository to not have been tampered with. In the absence of unlimited time and manpower, that’s the only smart option I see to upgrade anything complex on a RHEL system.

You can read the original outdated entry if you want by clicking below.

I wanted to upgrade a number of important items of software on my useless, out of date RHEL4 server. Of particular interest was Apache 2.2, and since i was updating Apache I also had to re-install PHP – may as well be the “new” PHP5, then. And since we’re throwing the packaging system completely out the window and going source the whole way, may as well throw in MySQL 5 for good measure.

So. This is going to be fun, fun, fun! Let’s get started. I made all the mistakes so you don’t have to.

Please note that I’m also going to throw all Red Hat conventions out the window and throw everything in /usr/local/. One wonders, doing all this shit by hand, what the hell the point of having RHEL is at all .. but that’s another story. Anyway, on with the show …

Step 1: MySQL 5.0.45

Backup all your databases

mysqldump -u root -p --all-databases > mysql_backup.dmp
 
cd /src (or whatever directory you use to put source files in)
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz
gunzip mysql-5.0.45.tar.gz
tar xvf mysql-5.0.45.tar
cd mysql-5.0.45
mkdir /usr/local/mysql
./configure --prefix=/usr/local/mysql
make
make install
cd ..

Step 2 – Apache 2.2.6

wget http://apache.planetmirror.com.au/dist/httpd/httpd-2.2.6.tar.gz
gunzip httpd-2.2.6.tar.gz
tar xvf httpd-2.2.6.tar
cd httpd-2.2.6
./configure --enable-module=most --enable-shared=max --enable-rewrite \
--enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-proxy-connect \
--enable-so --enable-ssl --enable-auth-digest 
make
make install
cd ..

Step 3 – PHP 5.2.4

I had to install libpng to get GD support working:

wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.20.tar.gz?download
gunzip libpng-1.2.20.tar.gz 
tar xvf libpng-1.2.20.tar 
cd libpng-1.2.20
/.configure
make
make install
cd ..

Now to the PHP:

wget http://www.php.net/get/php-5.2.4.tar.gz/from/a/mirror
gunzip php-5.2.4.tar.gz
tar xvf php-5.2.4.tar
cd php-5.2.4
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql \
--with-gd
make
make test
make install

Be careful to read carefully any warnings given in make install’s output, you may have to run an additional libtools command to generate the correct .so files for Apache.

And remember to

make clean

if you need to reconfigure PHP for any reason, or you’ll get horrible bugs that waste hours of your time to track down, like I did.

Step 4 – Modify RHEL Services Settings

There is probably a better way to change services settings in RHEL, but I don’t know what it is. So let’s just change them right under the OS’s nose:

/etc/init.d/httpd

modify any reference to the binaries to reflect their new location:

apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
..
CONFFILE=usr/local/apache2/conf/httpd.conf

/etc/init.d/mysqld

I am still trying to figure out how to do this step, and will update when I get it working – still using 4.1.20 for the time being …

3 Responses to “Upgrading Apache, MySQL and PHP on RHEL4 the FUN way”

  1. Wincent Colaiuta Says:

    Haven’t read this in detail but one thing that leaps out is your use of this pattern:

    gunzip httpd-2.2.6.tar.gz
    tar xvf httpd-2.2.6.tar

    This can instead be written:

    tar xzvf httpd-2.2.6.tar.gz

    And if it were a bz2 archive instead of a tgz you’d use tar xjvf instead of tar xzvf.

  2. Sho Says:

    Yeah, I know it can be done in one step, but I always forget the string of switches and so just do it manually. Seriously .. FOUR switches, just to extract a damn file?

    Probably would have ended up looking it up if I’d had many more to do.

    Anyway, you don’t need to read the article in full or anything, I just wanted a record of the fucking ./configure lines I used since it ended up taking an awfully long time. And furthermore, it’s still not running MySQL5 so is kind of a work in progess.

  3. Sho Says:

    I have actually scrapped this MySQL install and gone to the RPM version, which correctly replaces the init.d entries and more. However, PHP won’t compile against it and only seems to want to compile against the source-installed /usr/local version – same version, so seems OK.

    Lol, what a fucking mess. I would have preferred to simply move to RHEL5 but an in-place upgrade wasn’t available. Anyway all is working now, but I’d like to move to a cleaner system sooner rather than later. Actually, I’d like to move to virtual machines – fucking mother fuck having everything tied to hardware. I’d like to make one “reference VM” and deploy it on whatever I like .. want to upgrade? clone the VM and upgrade it, then if all is well migrate your production data to it .. or rebuild the VM from scratch.

    Much better, looking forward to doing that ASAP. I ain’t never going through this 2-day hell of forcing unsupported RHEL upgrades ever again, I can tell you!

Leave a Reply