24Okt/083
Apache2 mpm-worker und fcgid
Nachdem gefühlt der Apache auf dieser Website gelegentlich mal denkpausen gebraucht hat habe ich mich dazu entschlossen die mpm-prefork mit der mpm-worker Version zu ersetzen, zusätzlich wird nun PHP durch FastCGI aufgerufen.
Anbei eine kleine Konfigurationsanleitung.
- Installation der benötigten Pakete:
aptitude install libapache2-mod-fcgid apache2-mpm-worker php5-cgi
- Konfiguration des Apache
a2dismod php5 a2enmod actions a2enmod fcgid
- Anpassen der Apache Konfigurationen
/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 means that # 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
- Anlegen des Wrapper unter
/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 which is compiled with FCGI support. exec /usr/bin/php5-cgi
- den neuen Wrapper ausführbar machen
chmod +x /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper
- Schließlich muss der Apache noch neu gestartet werden
/etc/init.d/apache2 restart






November 5th, 2008
Etch?
Gerd
November 5th, 2008
mich würde wirklich interessieren, ob dein Server unter etch läuft. Ich hab nämlich genau das auch schon versucht (http://blog.it4sport.de/2008/09/05/fastcgi-mit-php5/) und nur schlechte Erfahrungen damit gemacht.
Gerd
November 5th, 2008
HI Gerd,
ja läuft unter Etch, nur der Kernel ist eigens gebaut, XCache kommt aus backports.
Michi