<:Getting around Gentoo's current PHP problems>

Dieser Artikel ist in Englisch, um möglichst viele Suchende zu erreichen.

Currently, there are some problems if you want to use bleeding-edge PHP5 and MySQL on a box running Gentoo Linux. I will describe what these problems are, why they are there and how to fix them.

Problem number one is the unmasking of PHP5. It is currently marked as "unstable" by the Gentoo developers. If you want to use it, you have to tell Portage that it should use the unstable version. Do this by adding the two lines dev-php/php and dev-php/mod_php to the file /etc/portage/package.keywords. If the file does not exist, create it. But sadly this alone won't help, because currently all PHP5 packages are hard-masked (see /usr/portage/profiles/package.mask and search for php). To unmask them, you would add something like >=dev-php/php-5.0.0 to /etc/portage/package.unmask. But this would also unmask the currently available php-5.1.0_beta packages, which you maybe do not want to use yet (I don't). So, in order to be able to use PHP 5.0.*, add the following lines to /etc/portage/package.unmask: <dev-php/php-5.0.99 and <dev-php/mod_php-5.0.99.

Problem number two are, if you're using the Apache Web Server, the Apache worker modules. Only mpm_prefork is currently compatible with PHP5, so you must disable all others, or strange stuff will happen. In order to do this, add net-www/apache -mpm-leader -mpm-peruser mpm-prefork -mpm-threadpool -mpm-worker to /etc/portage/package.use.

Third and last problem is MySQL 4.1, if you want to use it. Gentoo's PHP5 packages depend on MySQL 4.0 and will downgrade it, if you don't do anything against it. Since I definitely need MySQL 4.1's subqueries, here's what I did. First, if you have not already done this, create a local Portage overlay tree by issuing mkdir /usr/local/portage and adding the line PORTDIR_OVERLAY="/usr/local/portage" to your /etc/make.conf. Portage wants to downgrade MySQL, because the PHP5 eclass, which every PHP5 package uses, says it wants MySQL 4.0*. The devs won't fix this at the moment, because it will break stuff for people having mysqli in their USE flags but not having MySQL in their package.unmask, see Bug #53886. So, let's fix it ourselves because we know what we do (at least, I hope so). But be warned, MySQLi is said to be segfaulting quite often.

First, add dev-db/mysql to package.keywords and package.unmask. Then create a directory /usr/local/portage/eclass and copy /usr/portage/eclass/php5-sapi-r2.eclass over to it. Edit /usr/local/portage/eclass/php5-sapi-r2.eclass. Find the line saying mysql? ( =dev-db/mysql-4.0* ) and change it to mysql? ( =dev-db/mysql-4* ). Second, find the line saying if useq mysqli ; then and comment it and the following lines up to (including) the line fi out (by adding a # character at the beginning of each line).

You should now be able to use PHP 5.0.* and MySQL 4.1.*, and, if you USE mysqli, this as well. If not, drop me a line.

Update: Another idea, if you still have problems: Try deleting the whole /var/cache/edb directory. Thanks to Thread #345015 for pointing this out.