Michael `s blog OSS / Linux, networking and my private life

24 Okt/08 3

Apache2 mpm-worker and fcgid

After Apache has felt the occasional times used on this site breaks thinking I've decided to replace the mpm-prefork mpm-worker with the version that is now also called by PHP FastCGI.

Below is a small configuration instructions.

  • Installing the required packages:

  aptitude install libapache2-mod-fcgid apache2-mpm-worker php5-cgi 

  • Configuration of the Apache

  a2dismod php5
 actions a2enmod
 a2enmod fcgid 

  • Customizing the Apache Configuration

/ Etc/apache2/mods-enabled/fcgid.conf

 AddHandler fcgid-script. Fcgi
 Socketpath / var/lib/apache2/fcgid/sock
 IPCConnectTimeout 60 

/ Etc/apache2/conf.d/php5-fcgid.conf

 # Path to php.ini - defaults to / etc / phpX / cgi
 DefaultInitEnv PHPRC = / etc/php5/cgi

 # Number of PHP childs that will be launched.  Leave undefined to let PHP decide.
 DefaultInitEnv PHP_FCGI_CHILDREN # 3

 # Maximum requests before a process is stopped and a new one is launched
 DefaultInitEnv PHP_FCGI_MAX_REQUESTS 2500

 # Define a new handler "php-fcgi" for. "Php" files, plus the action that must follow
 AddHandler php-fcgi. Php
 Action php-fcgi / fcgi-bin/php-fcgi-wrapper

 # Define the MIME type for. "Php" files
 AddType application / x-httpd-php. Php

 # Define alias "/ fcgi-bin /".  The action above is using this value, Which that means
 # You could run another "php5-cgi" command by just changing this alias
 Alias ​​/ fcgi-bin / / var/www/fcgi-bin.d/php5-default /

 # Turn on the fcgid-script handler for all files within the alias "/ fcgi-bin /"

 SetHandler fcgid-script
 Options + ExecCGI 

  • Creating the wrapper with

/ Var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper

  # / Bin / sh
 # Wrapper for PHP-fcgi
 # This wrapper can be used to define settings before launching the PHP-fcgi binary.

 # Define the path to php.ini.  This defaults to / etc / phpX / cgi.
 # Export PHPRC = / var/www/fcgi-bin.d/php5-web01/phprc
 export PHPRC = / etc/php5/cgi

 # Define the number of PHP childs that will be launched.  Leave undefined to let PHP decide.
 export PHP_FCGI_CHILDREN = 5

 # Maximum requests before a process is stopped and a new one is launched
 export PHP_FCGI_MAX_REQUESTS = 5000

 # Launch the PHP CGI binary
 # This can be any other version of PHP is compiled with FCGI Which support.
 exec / usr/bin/php5-cgi 

  • the new wrapper to make it executable

  chmod + x / var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper 

  • Finally, Apache must be restarted again

  / Etc/init.d/apache2 restart 

Comments (3) Trackbacks (0)
  1. I would be really interested in, if your server is running under etch. That is exactly what I've already tried ( http://blog.it4sport.de/2008/09/05/fastcgi-mit-php5/ ) and made ​​only bad experiences with it.

    Gerd

  2. Hi Gerd,

    yes running under etch, only the kernel is specially constructed, XCache comes from backports.

    Michi


Leave a comment

(required)

No trackbacks.