PHP 5 and MySQL 4 on Fedora Core 3, from RPMs

by Marion Bates <mbates at whoopis.com>

This document describes the process I used to enable MySQL 4.1 and PHP 5.x, from RPMs (precompiled binaries), on a fresh Fedora Core 3 installation.


NOTES/ADDENDA:


Introduction: Normally, the popular MySQL and PHP packages are included in the Linux distribution itself, and that is indeed the case with FC3; however, it's MySQL 3.32 and PHP 4, each of which is a full version number behind. Yes, they're stable, but there are key features available in the more bleeding-edge releases (such as support for true transaction locking).

I could've compiled both from source, but installing programs with RPM is preferable because it vastly simplifies configuration changes and upgrades later. A full review of RPM is outside the scope of this document, but the most basic options are covered here.

  1. To upgrade MySQL 3.32 to 4.1, I had to first remove everything that was tied to the old MySQL:
    rpm -e perl-DBD-MySQL mysql mod_auth_mysql php-mysql libdbi-dbd-mysql MyODBC MySQL-python mysql-bench mysql-devel mysql-server
    
    If it complains about any of these being needed by other installed components, tack those components' names onto the end of the rpm command and try again. That's how I formed the command line above (I started with just "rpm -e mysql"). To check for all mysql-related packages in your installation, do
    rpm -qa | grep -i mysql
    

  2. Then download and install MySQL and all its parts for your system architecture from MySQL.com downloads page. Don't grab the "standard" package, but rather scroll down and find the individual packages for your distro/version. (In my case this was a 64-bit machine, so the rpm names below will differ for you if you're on another system):
    rpm -Uvh MySQL-server-4.1.8-0.glibc23.x86_64.rpm MySQL-client-4.1.8-0.glibc23.x86_64.rpm MySQL-devel-4.1.8-0.glibc23.x86_64.rpm MySQL-shared-4.1.8-0.glibc23.x86_64.rpm
    
    Then start mysqld, set initial password, all is well:
    /etc/init.d/mysql start
    mysqladmin -u root password 'mynewpassword'
    mysqladmin -h myfullyqualifiedhostname -u root password 'mynewpassword'
    

  3. Now, for php. First, remove old:
    rpm -e php-ldap php-pear php
    
    Check to make sure you got it all with
    rpm -qa | grep -i php
    

    The official php.net site does not distribute Linux binaries, so I went to RPMfind.net and grabbed them from the Fedora Core Development list. These are the ones I knew I wanted, but there may be others depending on what you're using PHP for:

    php-devel-5.0.2-8.x86_64.rpm
    php-pear-5.0.2-8.x86_64.rpm
    php-mysql-5.0.2-8.x86_64.rpm
    php-gd-5.0.2-8.x86_64.rpm
    php-5.0.2-8.x86_64.rpm
    
    Installation attempt:
    rpm -Uvh php-5.0.2-8.x86_64.rpm php-devel-5.0.2-8.x86_64.rpm php-mysql-5.0.2-8.x86_64.rpm php-pear-5.0.2-8.x86_64.rpm 
    
    And I got this error:
    error: Failed dependencies:
            libdb-4.3.so()(64bit) is needed by php-5.0.2-8.x86_64
    
    Turns out these are part of db4, the Berkeley DB database library (version 4).

  4. So I went back to rpmfind.net and got another FC Devel rpm and tried to install that:
    rpm -Uvh db4-4.3.21-1.x86_64.rpm 
    
    And now the uber-error:
    error: Failed dependencies:
            libdb-4.2.so()(64bit) is needed by (installed) perl-5.8.5-9.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) python-2.3.4-11.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) pam_ccreds-1-3.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) sendmail-8.13.1-2.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) apr-util-0.9.4-17.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) httpd-2.0.52-3.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) mod_perl-1.99_16-3.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) webalizer-2.01_10-25.x86_64
            libdb-4.2.so()(64bit) is needed by (installed) db4-utils-4.2.52-6.x86_64
    
    Uh-oh, what now?

  5. BILL TO THE RESCUE! This doesn't always work, but Bill Stearns suggests the following rule of thumb: When the version conflict has to do with libraries, try just "rpm -i" (Install) rather than -Uvh (Upgrade, Verbosely, and show progress with Hashmarks), in effect installing the new libraries alongside the old ones.
    rpm -i db4-4.3.21-1.x86_64.rpm 
    
    worked in this case. If all hell breaks loose, rpm -e it.

    If you get other failed deps, try installing the correct version first (e.g. "yum install curl" fixed things when rpm whined about missing libcurl). Fall back on the development tree only when you have no other choice.

  6. Finally,
    rpm -Uvh php-5.0.2-8.x86_64.rpm php-devel-5.0.2-8.x86_64.rpm php-mysql-5.0.2-8.x86_64.rpm php-pear-5.0.2-8.x86_64.rpm php-gd-5.0.2-8.x86_64.rpm
    
    and DONE! PHP 5, MySQL 4, and Fedora Core 3, all playing nicely together.


References: