Blog » Blog Entry

PHP 5 and MySQL 4.1 on Gentoo Linux 2005.1

September 3, 2005

In case you weren't aware, the current availability of PHP 5 and MySQL 4.1 on Gentoo Linux is pretty much non-existent. Many PHP/MySQL developers using Gentoo Linux are frustrated and fed up with waiting on the Gentoo developers to repair the broken ebuilds currently in portage. Worse than that, instead of fixing the broken ebuilds, time is being wasted developing alternate ways of installing PHP5 called 'overlays'. These alternate ways of upgrading your PHP to the latest stable do not work to say the least.

I wasted nearly two days reading Gentoo Forum posts and various how-tos, trying the suggested methods to install PHP 5 and MySQL 4.1 on my Gentoo system. Finally I gave up and installed PHP 5 and MySQL 4.1 from source. After making a few tweaks to my system I now have exactly the software versions I want. Here is what I did:

I took out my existing PHP and MySQL installs:

emerge -C php mod_php mysql

Next I downloaded the latest stable MySQL source from http://mysql.com/. I got the mysql-4.1.14.tar.gz distribution.

I uncompressed it:

tar zxvf mysql-4.1.14.tar.gz

Then I built it and installed it:

cd mysql-4.1.14
./configure
make
su
make install

I copied a new my.cnf file into /etc:

cp support-files/my-medium.cnf /etc/my.cnf

Previously I had MySQL 4.0.x on my system I wanted my new MySQL 4.1 to use the 4.0 data. I placed the following in my /etc/conf.d/local.start so when MySQL started up it would use my existing error log and data directory:

/usr/local/bin/mysqld_safe \
  --err-log=/var/log/mysql/mysqld.err \
  --datadir=/var/lib/mysql &

When MySQL started up I noticed in the log files it complained about me needing to upgrade my MySQL passwords, so I did:

mysql_fix_privilege_tables --user=root \
--password=passwd --verbose

At this point I rebooted to make sure MySQL was starting on boot. I noticed an error message coming from Apache. It was dependant on MySQL and as far as Gentoo was concerned I had no MySQL installed. So I edited the depend() function in /etc/init.d/apache2 so Apache was no longer dependant on MySQL.

I also discovered my Pure-FTPd install was producing some errors about missing MySQL libraries. I edited /etc/portage/package.use and added an entry:

net-ftp/pure-ftpd -mysql

I never use the MySQL support with Pure-FTPd anyway. I re-emerged Pure-FTPd and restarted it. Fixed.

MySQL was working fine at this point. My mysql.sock file changed however. Mostly cause I didn't take time to configure it to be in the same place as before, nor did I specify the socket location in my my.cnf file. No big deal, the only thing complaining about it was one of my Ruby On Rails projects and I fixed that in config/database.yml by adding a socket definition:

socket: /tmp/mysql.sock

Next I began to install PHP 5.

I downloaded the latest stable PHP 5 source from http://php.net/. I got the php-5.0.4.tar.bz2 distribution.

I uncompressed it:

tar jxvf php-5.0.4.tar.bz2

Then I built it and installed it:

cd php-5.0.4
./configure \
  --with-apxs2=/usr/sbin/apxs2 \
  --with-gd \
  --enable-sockets \
  --with-zlib \
  --with-mysqli \
  --with-mysql=/usr \
  --with-freetype-dir=/usr \
  --with-jpeg-dir=/usr \
  --with-png-dir=/usr \
  --enable-mbstring
make
su
make install

I edit the APACHE2_OPTS in /etc/conf.d/apache2 and removed '-D PHP4'.

I edited /etc/apache2/conf/apache2.conf and added:

AddType application/x-httpd-php .php
just under the PHP 5 module entry:
LoadModule php5_module  lib/apache2/modules/libphp5.so

I restarted Apache:

> /etc/init.d/apache2 restart
 * Caching service dependencies ...             [ ok ]
 * Stopping apache2 ...                         [ ok ]
 * Starting apache2 ...                         [ ok ]

I pulled up a phpinfo() page and everything looked good. I accessed my phpMyAdmin install and everything worked fine.

Good luck with those PHP overlays Stu.

Tags: php, gentoo, mysql

« Debian is the one Newlines »

Add a comment:

Title:

Comment:

Name:

Email: