Miriam Ruiz
random thoughts on technology and life

{August 17, 2009}   Making PHP stuff properly work in Apache2 with apache2-mpm-worker

I’ve been lately playing with 389 Directory Server (previously Fedora Directory Server, previously Netscape Directory Server). Along with the LDAP server itself comes an admin tool and a console GUI for managing the system. The admin tool is built on Apache2, and it needs it to use the worker MPM (high speed threaded model), provided by the package apache2-mpm-worker. The problem is that libapache2-mod-php5 seems to depend on apache2-mpm-prefork, so I have to use php5-cgi to provide the PHP scripting functionality instead. That seems to work properly out-of-the-box ™ for stuff like phpldapadmin, but not so properly for phpmyadmin and phppgadmin. In those cases the browser seems to try to download the PHP script instead of executing it.

The quickest solution for that is to add some configuration stuff to Apache2, telling it to do things properly:

# cd /etc/apache2/mods-available/
# cat >> php5-cgi.conf
<IfModule !mod_php5.c>
  <IfModule mod_actions.c>
    <IfModule mod_cgi.c>
      AddType application/x-httpd-php .php .phtml .php3
      Action application/x-httpd-php /cgi-bin/php5
    <IfModule mod_cgid.c>
      AddType application/x-httpd-php .php .phtml .php3
      Action application/x-httpd-php /cgi-bin/php5
# cd ../mods-enabled/
# ln -s ../mods-available/php5-cgi.conf
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

That should do the trick. Don’t forget to restart Iceweasel/Firefox, or some kind of caches inside it will keep trying to download the PHP scripts anyway.

Russell Coker says:

Does SHIFT-F5 work on Iceweasel? Generally the only things that make me restart Iceweasel are when there is a security fix and when the memory leaks get excessive. Running Iceweasel for a month is not uncommon for me.

Why does the admin tool require the threaded version of Apache? Is it an Apache module or something?

Albert says:

I’ve found libapache2-mod-fcgid to work very well with apache2-mpm-worker.

Miry says:

Albert: I haven’t tried it, but I will, thanks!

That has nothing to do with the fact that PHP files are not handled correctly when using php5-cgi instead of libapache2_mod_php5 by default, or does it work out of the box without the fix I mentioned?

I haven’t tried libapache2-mod-suphp either.

niq says:

mod_fcgid is a widely-recommended solution these days for PHP (Albert seems already to have identified a debian package of it).

It has recently been donated to Apache, relicensed, and should be included as standard in future Apache releases (2.4; not just introduced in some delta of 2.2).

G.K. says:

Why the heck does an admin-tool depend on Apache´s worker version?
That´s kinda rediculous to me…
Btw: AFAIK the worker does not cope with mod_php since the php module is not thread safe…


JanC says:

I think last I heard was that mod_php itself is thread-safe now, but some of the PHP libraries are not, and if you use those with mpm_worker you can expect trouble…

Unfortunately I don’t know which PHP libraries are either thread-safe or not.

Leave a Reply


This is a personal webpage that belongs to Miriam Ruiz.
If you want to contact her, you can do at:

August 2019
« Nov    

La Lista de Sinde