mod_fcgid is a high performance alternative to mod_cgi or mod_cgid, which starts a sufficient number instances of the CGI program to handle concurrent requests, and these programs remain running to handle further incoming requests. It is favored by the PHP developers, for example, as a preferred alternative to running mod_php in-process, delivering very similar performance.
Lets see how to configure Mod_fcgid (Fastcgi) in CentOS Web Panel
1) Install Apache 2.2.
cd /tmp/apache-build/httpd-2.2.27 rm -rf /usr/local/apache/conf/httpd.conf make distclean ./configure --enable-so --prefix=/usr/local/apache --with-mpm=worker --enable-ssl --enable-unique-id --enable-ssl=/usr/include/openssl --enable-rewrite --enable-deflate --enable-suexec --with-suexec-docroot="/home" --with-suexec-caller="nobody" --with-suexec-logfile="/usr/local/apache/logs/suexec_log" --enable-asis --enable-filter --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --enable-headers --enable-expires --enable-proxy --enable-cgi --enable-rewrite --enable-spelling --enable-version make && make install echo "Include /usr/local/apache/conf/sharedip.conf" >> /usr/local/apache/conf/httpd.conf echo "Include /usr/local/apache/conf.d/*.conf" >> /usr/local/apache/conf/httpd.conf sed -i "s|DirectoryIndex index.html|DirectoryIndex index.php index.html|g" /usr/local/apache/conf/httpd.conf sed -i "s|User daemon|User nobody|g" /usr/local/apache/conf/httpd.conf sed -i "s|Group daemon|Group nobody|g" /usr/local/apache/conf/httpd.conf sed -i "s|.*modules/libphp5.so.*||g" /usr/local/apache/conf/httpd.conf rm -rf /usr/local/apache/conf.d/suphp.conf PATH=$PATH:/usr/local/apache/bin
2) Install Mod_fcgid.
cd /tmp rm -rf mod_fcgid svn checkout http://svn.apache.org/repos/asf/httpd/mod_fcgid/trunk mod_fcgid cd mod_fcgid ./configure.apxs make && make install
3) Install PHP 5.4.
cd /tmp/php-build/php-5.4.27 make distclean ./configure --with-zlib --with-zlib-dir=/usr --with-bz2 --enable-soap --enable-exif -with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --enable-phar --enable-bcmath --enable-calendar --with-curl --with-iconv --with-mysql --with-mysqli --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mcrypt --with-mhash --with-gettext --with-xsl --with-xmlrpc --with-pdo-mysql=mysqlnd --enable-posix --enable-ftp --with-openssl --enable-mbstring --with-jpeg-dir=/usr --with-freetype-dir=/usr -with-png-dir=/usr --with-libxml-dir=/usr --with-kerberos --with-xsl --with-bz2 --enable-sockets --enable-zip --with-gd --enable-gd-native-ttf --enable-sockets --with-pcre-regex --libdir=/usr/lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock make && make install rm -rf /usr/local/php/php.ini cp php.ini-production /usr/local/php/php.ini sed -i "s|.*modules/libphp5.so.*||g" /usr/local/apache/conf/httpd.conf echo 'cgi.fix_pathinfo = 1' >> /usr/local/php/php.ini echo 'PHP_Fix_Pathinfo_Enable 1' >> /usr/local/php/php.ini
4) Configure Mod_fcgid to run with Apache.
rm -rf /usr/local/apache/conf.d/fcgid.conf wget --output-document="/usr/local/apache/conf.d/fcgid.conf" http://dl-package.bullten.in/cwp/files/mod_fcgid/fcgid.txt
Apache is now configured to use FastCgi as Handler. However, before it correctly delivers your webpage we need to do couple of setting.
A) Setting Vhost [/usr/local/apache/conf.d/vhosts.conf]
For every virtual host we need to add FCGIWrapper and ExecCGI in Directory index. Like mentioned in below url:
$USERNAME is username of your account.
http://dl-package.bullten.in/cwp/files/mod_fcgid/vhost-example.txt
B) Create php-fcgi-starter to work with virtual host as above.
$USERNAME is username of your account.
mkdir -p /home/$USERNAME/public_html/cgi-bin
nano /home/$USERNAME/public_html/cgi-bin/php-fcgi-starter
#!/bin/sh PHPRC=/usr/local/php/ export PHPRC export PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_CHILDREN=8 exec /usr/local/php/bin/php-cgi
chmod +x php-fcgi-starter
chown -R $USERNAME:$USERNAME /home/$USERNAME/public_html/*
C) Restart Apache.
service httpd restart
You are now serving PHP pages with FastCgi (mod_fcgid)