14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

php-fpm の動作確認

Posted at

概要

  • docker で nginx と php-fpm を別々のDockerコンテナで構築する際
    nginx => 9000Port => php-fpm でどうしてもアクセスできなかった
  • 9000Port はhttpプロトコルではなくfastcgiなプロトコルなので確認しづらい
  • cgi-fcgi コマンドを利用することで、レスポンスが返却されるか確認出る

install

CentOS

yum --enablerepo=epel install fcgi

ubuntu(未確認)

apt-get install libfcgi0ldbl

接続テスト

  • 確認用スクリプトの設置
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php 
  • リクエスト
SCRIPT_NAME=index.php \
SCRIPT_FILENAME=/var/www/html/index.php \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9000
  • レスポンスが返却されれば成功!
X-Powered-By: PHP/7.2.10
Content-type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<style type="text/css">
/*以下略*/

その他

コマンドHELP

  • UNIX domain socket も対応していそうです。
[root@ee1633ae5f0c /]# cgi-fcgi --help
Unknown option --help
Missing application pathname
Missing -connect <connName>
Usage:
    cgi-fcgi -f <cmdPath> , or
    cgi-fcgi -connect <connName> <appPath> [<nServers>] , or
    cgi-fcgi -start -connect <connName> <appPath> [<nServers>] , or
    cgi-fcgi -bind -connect <connName> ,
where <connName> is either the pathname of a UNIX domain socket
or (if -bind is given) a hostName:portNumber specification
or (if -start is given) a :portNumber specification (uses local host).

参考

14
12
0

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
14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?