3
2

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 3 years have passed since last update.

Caddy2でPHPを動かしたい

Posted at

環境
Win10 AMD64

構成

C:/
    tool/
        caddy/
            caddy.exe
    exapmle/
        Caddyfile
		php.ini
    ver/
        a.html
		index.php
	php/
		....
		php-cgi.exe
		php.exe

各種インストール

Caddy2

前回書いた Caddyの使い方メモを参照

php_fastcgiに設定するアドレスは php-cgi-bオプションに設定するアドレス

Caddyfile
http://localhost {
	root * C:/ver/
	php_fastcgi http://localhost:2020
}

PHP8

PHP8 ダウンロード
今回使うのはPHP8のNon Thread Safe版を使う。
zipの中身をC:/php/に展開しPATHC:/phpを追加

PHPのパスが通った事を確認
php -v
パスが通っていればこんな感じ
PHP 8.0.0 (cli) (built: Nov 24 2020 22:02:58) ( NTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
php.iniを設置
cp C:/php/php.ini-production C:/exapmle/php.ini

古より受け継がれし伝統phpinfo()を用意しておく

/ver/index.php
<?php phpinfo(); ?>

起動

ターミナルを2つ立ち上げる

fastcgiを立ち上げ
cd C:/example
php-cgi -b localhost:2020
Caddyサーバ立ち上げ
cd C:/example
caddy run

http://localhost にアクセスし、phpinfo()が実行されたことを確認する。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?