[php-maint] PHP with MySQL support and compability with other apache modules that use MySQL

Jonas Meurer jonas at freesources.org
Wed Oct 19 14:36:24 UTC 2005


I'm the maintainer of python-mysqldb, and recently Ales Kozumplik reported
bug #333117: "apache2 + python + php + mysql not working".

The bugreport claims that mysql functions provided by python-mysqldb do
not work with mod_python, when apache has both mod_python and mod_php4
loaded, while they work perfectly when you run them directly as python
cgi script.

After investigating the bug and conversation with the python-mysqldb
upstream author, I'm quite sure that the problem is the php4 apache
module, or even better, it's mysql extension.

The python-mysqldb upstream author, Andy Dustmann pointed me to two
interesting links:

especially the second one is interessting, as it pointed me to the php4
configure script:

<---snip http://www.modpython.org/FAQ/faqw.py?req=all#2.13 --->
In my httpd.conf I was loading two DSO modules: mod_python and php4. It
turns out, when I removed the reference to php4, the mod_python worked
perfectly. Now, why was this? Well, I went back to the php4 module, and
checked out "configure" - if you know anything about php, it was being
configured with the "--with-mysql" flag, which tells it to use an
"internal" version of mysql libs. Apparently, this is fine - as long as
*no other modules use mysql* (the php configure tells you this at the
end). If they do, you should specify the actual mysql library directory.
Well, mod_python was basically another module using mysql. Duuuuh!
(well, not so obvious to me, really). When I specified the actual mysql
library to php configure, and recompiled and reinstalled the PHP, I
could have LoadModules for both php and mod_python and both appear to

and the relevant part in the configure script of php4:

<---snip php4-4.4.0/configure--->
  if test "$MYSQL_MODULE_TYPE" = "builtin" && test "$PHP_SAPI" != "cgi" \
	&& test "$PHP_SAPI" != "cli" && test \
	"$php_multiple_shlib_versions_ok" != "yes"; then
cat <<X
|                        *** WARNING ***                             |
|                                                                    |
| You chose to compile PHP with the built-in MySQL support.  If you  |
| are compiling a server module, and intend to use other server      |
| modules that also use MySQL (e.g, mod_auth_mysql, PHP 3.0,         |
| mod_perl) you must NOT rely on PHP's built-in MySQL support, and   |
| instead build it with your local MySQL support files, by adding    |
| --with-mysql=/path/to/mysql to your configure line.                |

i don't know whether this applies to php5 as well, but at least php4
should be rebuilt with a specific mysql version to make it possible to
load more than one apache module with mysql support.

another option for python-mysqldb would be to Conflict with php4-mysql,
but that is a dirty solution, as it makes it impossible to use both
php4-mysql and python-mysqldb on one system.

i'm not sure about what solution to prefer, as compiling php4 against a
specific mysql version would restrict the users of php4-mysql to one
specific mysql version, but the current situation is not acceptable as

should i reassign bug #333117 to php4-mysql, or clone it?

i hope that you have suggestions about how to fix that situation.


More information about the pkg-php-maint mailing list