お知らせ

現在サイトのリニューアル作業中のため、全体的にページの表示が乱れています。

Windows + nginxでPHPを動作させる

投稿日:
OS::Windowsミドルウェア::HTTPD::nginx言語::PHP

確認環境

Env Ver
Windows 10 pro
PHP 8.0.2 NTS Visual C++ 2019 x64
nginx 1.19.8

手順

  1. nginx.confを開きFastCGI server listening on 127.0.0.1:9000辺りに次の設定をする
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  C:/nginx/html/$fastcgi_script_name;
    include        fastcgi_params;
}
  1. 設定したフォルダに.phpファイルを配置
  2. nginxを起動
  3. php-cgi.exe -b 127.0.0.1:9000
  4. .phpファイルにアクセス

サービス化する

  • winswを使うとできるらしい