• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

mod_fastcgi Installation on Apache 2.2

How to install mod_fastcgi

What is mod_fastcgi?

mod_fastcgi is an Apache module for interfacing with CGI programs allowing a server to handle more requests at  one time.  It does this by keeping an instance of php running in the background. When apache receives the request it forwards it to FasctCGI. It can increase performance and reduce memory useage over mod_php. If you have not already done so, you will need to setup php-fpm for this to work. Please the following guide on how to do so Install PHP-FPM

Install mod_fastcgi

First get the required the required packages

wget -O /usr/src/mod_fastcgi-2.4.6.tar.gz https://github.com/txduncan/mod_fastcgi/blob/master/mod_fastcgi-2.4.6.tar.gz

Change to the download directory:

cd /usr/src

Uncompress the package:

tar xfvz mod_fastcgi-2.4.6.tar.gz

Copy the make file:

cp /usr/src/mod_fastcgi-2.4.6/Makefile.AP2 /usr/src/mod_fastcgi-2.4.6/Makefile

Make and install the package

make top_dir=/usr/lib64/httpd
 make top_dir=/usr/lib64/httpd install

If the build directory differs from the standard apache build you will need to update top_dir to the parent directory of the build directory

Configure Apache to use mod_fastcgi

Edit /etc/httpd/conf/httpd.conf and add

LoadModule fastcgi_module lib/apache/mod_fastcgi.so

To make the entire Apache server to use php-fpm with mod_fastcgi:

Comment out any additional references to php in httpd.conf

# LoadModule php5_module        modules/libphp5.so
# AddType application/x-httpd-php .php

Edit /etc/httpd/conf/httpd.conf and add the following

LoadModule fastcgi_module modules/mod_fastcgi.so

Edit /etc/httpd/conf.d/fastcgi.conf and add the following

<IfModule mod_fastcgi.c> 
 FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000
 AddHandler php-fastcgi .php 
  Action php-fastcgi /usr/sbin/php-fpm.fcgi 
 ScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm 
 <Directory /usr/sbin> 
 Options ExecCGI FollowSymLinks 
 SetHandler fastcgi-script 
 Order allow,deny 
 Allow from all 
 </Directory> 
 </IfModule>

Be sure to update the path to the php-fpm binary in the above configuration, to find it do:

which php-fpm

Add a include in /etc/httpd/conf/httpd.conf

Include /etc/httpd/conf.d/fastcgi.conf

 

Restart Apache to load the new configuration:

service httpd restart

Once you have done that go ahead and create a test file in a Apache document root:

<?php
 phpinfo();
 ?>

Visiting that page should show the PHP variables from the newly configured mod_fastcgi.

 

May 21, 2017LinuxAdmin.io
0 0 vote
Article Rating
Setup Nginx Virtual Hosts On CentOSmod_proxy Installation and Configuration on Apache
You Might Also Like
 
How To Install And Configure mod_auth_mysql On Apache
 
mod_auth_token Installation In Apache
Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments
5 years ago Apache, Linux System Administration, Web Hosting 2,867
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
63,002 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,912 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz