Question

How to Install FastCGI on CentOS

Hi,

I hope these info are important. Following are already installed. OS: CentOS 7.0 x64 Apache 2.4 MySQL 5.5 PHP 5.4.36

I want to install FastCGI on this. I googled and found several tutorials. But the commands used in them are different from each other and Im confused. If someone can give me a step by step on how to install latest FastCGI on a server that already have above things, I would really appreciate it.

Thanks

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @admin1009248,

Let’s say you didn’t have FastCGI installed.

We’ll install it as an Apache module.

yum install php php-cli mod_fcgid

As soon as you have it installed for your PHP version, you’ll need to disable the default PHP Handler. Edit PHP configuration file for Apache - /etc/httpd/conf.d/php.conf in your favorite text editor and comment the following lines in it

<FileMatch \.php$>
    SetHandler application/x-httpd-php
</FileMatch>

Save the file and restart apache as

service httpd restart

Now you’ll need to setup your FastCGI.Nagigate to /var/www/cgi-bin directory, If it doesn’t exist, create the directory. Then create a php.fastcgi file and add the following content to this file. Also make sure the php.ini file and php-cgi exist on your system:

vim /var/www/cgi-bin/php.fastcgi

The content of the file should be something like

#!/bin/bash

PHPRC="/etc/php.ini"
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi

Now you’ll need to actually have the proper ownership and you can execute the them like so

chown apache:apache /var/www/cgi-bin/php.fastcgi
chmod +x /var/www/cgi-bin/php.fastcgi

Now you have FCGI installed and you can actually use it to setup your Vhost files.

Regards, KDSys

This comment has been deleted