LoginSignup
4

More than 3 years have passed since last update.

fcgi コマンドでターミナルから php-fpm(FastCGI)の動作を確認する

Posted at

以下の記事とほぼ同じ内容ですが、Mac OS X で確認したときのメモ。

php-fpm の動作確認
Directly connect to PHP-FPM

やりたかったこと

  • nginx から FastCGI で php-fpm へ接続するテストをしたい
  • php-fpm のみの動作を確認したい
  • php-fpm は HTTP ではないので curl で確認できない

対応方法

cgi-fcgi というコマンドで FastCGI の確認ができるようなので使ってみる。
Mac OS X ならインストールは HomeBrew で可能。

fcgi

$brew install fcgi

実際に確認してみる。

$docker run -p 9000:9000 -d  php:7-fpm

# cgi-fcgi を利用した接続テスト
$REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9000
X-Powered-By: PHP/7.4.6
Content-type: text/html; charset=UTF-8

# ログより接続を確認
$docker logs 187afd220bc3
[06-Jun-2020 08:25:09] NOTICE: fpm is running, pid 1
[06-Jun-2020 08:25:09] NOTICE: ready to handle connections
172.17.0.1 -  06/Jun/2020:08:25:16 +0000 "- " 200

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4