Quickly test FastCGI

Connecting directly to PHP-FPM

Fullstack CTO
1 min readOct 5, 2022

When working with docker containers, particularly when configuring PHP, you may need to quickly check the availability of the raised PHP. There is a good tool for this purpose: cgi-fcgi .

Installing

On RHEL/CentOS it is easy and simple to install with the following command:

yum --enablerepo=epel install fcgi

In Ubuntu, the name of the tool and the syntax for installing it is slightly different:

apt-get install libfcgi0ldbl

Checking PHP-FPM

It is very easy to check if php-fpm is working:

cgi-fcgi -bind -connect 127.0.0.1:9000

If necessary (if the ping settings have been changed via a configuration file), you can set the parameters via environment variables:

SCRIPT_NAME=/ping \
SCRIPT_FILENAME=/ping \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9000

We will get this answer:

Content-Type: text/plain
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
pong

This way you can also check the status page or some arbitrary URL, although you can also use wget, curl, telnet…

--

--

Fullstack CTO
Fullstack CTO

Written by Fullstack CTO

CTO and co-founder at NEWHR & Geekjob

No responses yet