Virtualmin: “PHP execution via fcgid requires the Apache mod_fcgid module”

apache-2.2mod-fastcgimod-fcgid

I have a CentOS server with Virtualmin on it. I have configured PHP the way I want it, using Apache mod_fastcgi. However, when I click "Re-check Config" in Virtualmin, I get

PHP execution via fcgid requires the Apache mod_fcgid module

This post says to change Default PHP execution mode to CGI, but I can't find such an option anywhere!

Best Answer

mod_fastcgi (www.fastcgi.com) is a 3rd-party module whose directives have a "FastCgi" prefix.

mod_fcgid http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html is an Apache module whose directives have a "Fcgid" prefix.

I advise that you remove mod_fastcgi and go with mod_fcgid.

That's great news for PHP, because then you can dump apache mpm-prefork and go with the better mpm-worker, by not installing mod_php, instead use php as fast cgi. For debian, this means:

• Remove apache2-mpm-prefork and libapache2-mod-php5.

• Add apache2-mpm-worker, libapache2-mod-fcgid, and php5-cgi. With php5-cgi, you don't need a custom fast cgi wrapper, you can use the php command-line itself directly (notice the /usr/lib/cgi-bin/php5) below.

• For mod_fcgid with PHP, note that PHP as FastCGI has its own facility for terminating after handling so many requests (see PHP_FCGI_MAX_REQUESTS). FcgidMaxRequestsPerProcess helps avoid sending additional requests to the wrapper application after it has handled its limit.

• Inside each virtual host or at global scope:

    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 200
    FcgidMaxRequestsPerProcess 200

• Then inside Directory:

    AddHandler fcgid-script .php
    FcgidWrapper /usr/lib/cgi-bin/php5 .php
    Options +ExecCGI