welcome to the world of…

Looks like a small bulb used to indicate something unusual, like a malfunction.

Transition to FastCGI

Filed under: Uncategorized — Tags: , , , , , , , , — admin @ 2009-05-08 17:36

Apache’s prefork MPM is a very heavy memory eater. Thirty instances together with PostgreSQL can consume more then 1.5GB of memory. I have already managed the PostgreSQL to become modest. Now the Apache is the target.

I need to decrease the memory consumption or decrease the processes count. How about worker MPM? It uses more threads than processes.

I’m running a lot’s of applications mostly with mod-python. But I need PHP for applications like phpmyadmin and Horde. Biggest issue is how to replace mod-php which depends on the prefork MPM because it is not thread-safe. Solution can be found in FastCGI. Let’s try it:

  1. get rid of apache2-mpm-prefork and libapache2-mod-php5 and install apache2-mpm-worker and php5-cgi.
  2. Configure Apache. You can find a lots of examples on the internet how to simply configure PHP+FastCGI. For eager beavers a quick tour:
    1. enable Apache’s action and fastcgi modules.
    2. put following lines in Apache’s configuration:
      AddType application/x-httpd-php .php
      AddHandler php5-fastcgi .php
      Action php5-fastcgi /cgi-bin/php5

Voila! Simple PHP scripts works!

But first problem arises. I can’t get into phpmyadmin. Firefox wants to download the page as PHTML. Solution is to clear the Firefox’s cache.

Another and harder problem comes. I have some .htaccess files with PHP directives (like php_flag). Now they doesn’t work because they worked only with mod-php. And generaly it will not work with FastCGI anyway. Some suggestions can be found e.g. in H-Sphere forum. Well you have to go around 🙂

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.