PHP 5 and MySQL 4 on Fedora Core 3, from RPMs
From ChekMate Security Group
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:
- Having trouble with old MySQL clients after upgrading to MySQL 4.1? Errors like "Client does not support authentication protocol requested by server; consider upgrading MySQL client"? Here is the solution: http://www.whoopis.com/howtos/mysql-auth-fix.html
- Missing the Pear DB.php stuff? Turns out that with PHP5's Pear RPM, only the files necessary to install Pear are included. To add DB.php, do:
pear install DB
You should see something like
downloading DB-1.6.8.tgz ... Starting to download DB-1.6.8.tgz (92,460 bytes) .....................done: 92,460 bytes install ok: DB 1.6.8
and find the file under /usr/share/pear/DB.php.
MySQL startup: The problem, as described by two readers, is that the installation seemed to go fine, but when they tried to start the MySQL server, it failed silently. In at least one case, /var/log/mysqld.log showed stuff like
050126 00:31:40 mysqld started 050126 0:31:40 Warning: Can't create test file /var/lib/mysql/localhost.lower-test 050126 0:31:40 Can't start server : Bind on unix socket: Permission denied 050126 0:31:40 Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ? 050126 0:31:40 Aborting
Well, today I finally found what may be the solution. Short version:
- Remove the database with # rm -rf /var/lib/mysql
- Temporarily disable selinux with # /usr/sbin/setenforce 0
- Initialize and start mysql with # /etc/init.d/mysql start
- Enable selinux again with # /usr/sbin/setenforce 1
See the Unix man pages for setenforce here.
Details: http://www.broadbandreports.com/forum/remark,12248933~mode=flat More details: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=141062
If you still have a problem after trying this, please email me.
Justin Mitchell <justinhomi at gmail -dot- com> wrote the following:
I followed the link you gave and successfully installed MySQL 4.0 and 4.1. There is one "catch". Once I turn selinux back on, MySQL fails to work (can't view databases).
The way to fix this permanantly is to disable selinux's policy for mysql. There are two ways::
Edit /etc/selinux/targeted and set mysqld_disable_trans=1 (from 0).
This can also be done using the Security Level tool found in the System Settings menu in the gnome applications menu.
You must restart the computer after applying this fix.
One more wrinkle: In one instance, I dunno why, but I had to blow away /var/lib/mysql/ and re-install the server component using the --force RPM option, before the server would start. ???
- PHP Session directory permissions: Doug Wolfgram <doug at gfx dot com> writes:
I also found that with your install procedure, someone left out the permissions setting on the php session directory. It should have been done as part of the php rpm install. Folks need to set it to 1777.
- PHPMyAdmin: Dan Maday <danmaday at yahoo dot com> writes:
I wanted to bring something to your attention that you might want ro share with the public who discover your website. PhpMyAdmin, the most popular remote MySql admin tool in Linux, has a problem with Fedora Core 3. It gives an Error 2002 MySql error when you try to connect. It drove me crazy searching the internet for an answer. Finally I found the problem was Selinux(sp?). Selinux secures httpd and causes phpMyAdmin to receive a MySql error when it tries to query the MySql server. The simple answer is to unsecure httpd. There is a much more exotic answer about special domains which can be found on the fedora-rehat.com page in the Nov 2004 messages. The answer was very sophisticated - way beyond me - so I only read the first two sentences and gave up.
- openssl libraries caveat: Martin Levy <mahtin at mahtin dot com> writes:
I didn't realize it was that hard... until I got into the process. I ended up with other issues than you (I was on a classic i386 platform).
In my case, I had to manually install the openssl lib's and then use "rpm -i --nodep" later on. This was because all I was missing was the newer versions of the dynamic lib's, but if I installed the whole rpm, I would have been in dependency-hell. This way, I have two lib's, one for the whole system and one for php to use.
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. See the Unix man pages for rpm 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 http://dev.mysql.com/downloads/mysql/4.1.html. 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 rpm -Uvh MySQL-client-4.1.8-0.glibc23.x86_64.rpm rpm -Uvh MySQL-devel-4.1.8-0.glibc23.x86_64.rpm rpm -Uvh 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 http://www.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 rpm -Uvh php-devel-5.0.2-8.x86_64.rpm rpm -Uvh php-mysql-5.0.2-8.x86_64.rpm rpm -Uvh 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 rpm -Uvh php-devel-5.0.2-8.x86_64.rpm rpm -Uvh php-mysql-5.0.2-8.x86_64.rpm rpm -Uvh php-pear-5.0.2-8.x86_64.rpm rpm -Uvh php-gd-5.0.2-8.x86_64.rpm
and DONE! PHP 5, MySQL 4, and Fedora Core 3, all playing nicely together.




