Question

How to Install FastCGI on CentOS

Posted January 22, 2015 4.1k views

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

2 comments
  • As I see from a little research I made its already working without any further configuration, but I might be wrong. So to see if its working properly you should create a info.php file in /var/www/html/ and add the following line inside:
    <?php phpinfo(); ?>

  • I already have a phpinfo file. What should I look for to confirm if its installed.

    Thanks

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.

2 answers

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

Submit an Answer