I've recently switched to a FastCGI setup for PHP (Apache2-worker and mod_fcgid
). However, when a single PHP script is very busy, it seems to block all other PHP requests. What would be wrong with my configuration?
My main reason for using mod_fcgid
is to keep PHP memory usage under control. With mod_php
, all individual Apache forks grow in memory after serving PHP.
I've also switched to the apache2-worker model, since there all thread-unsafe PHP code exists outside Apache.
My FastCGI script looks like:
#!/bin/sh #export PHPRC=/etc/php/fastcgi/ export PHP_FCGI_CHILDREN=5 export PHP_FCGI_MAX_REQUESTS=5000 global_root=/srv/www/vhosts.d/ exec /usr/bin/php-cgi5 \ -d open_basedir=$global_root:/tmp:/usr/share/php5:/var/lib/php5 \ -d disable_functions="exec,shell_exec,system"
My Apache config looks like this:
<IfModule fcgid_module> FcgidIPCDir /var/lib/apache2/fcgid/ FcgidProcessTableFile /var/lib/apache2/fcgid/shm FcgidMaxProcessesPerClass 1 FcgidInitialEnv RAILS_ENV production FcgidIOTimeout 600 AddHandler fcgid-script .fcgi FcgidConnectTimeout 20 MaxRequestLen 16777216 <FilesMatch "\.php$"> AddHandler fcgid-script .php Options +ExecCGI FcgidWrapper /srv/www/cgi-bin/php5-wrapper.sh .php </FilesMatch> DirectoryIndex index.php </IfModule>