PHPインストール方法(Windows IIS環境)

  1. Windowsの機能の有効化または無効化からFastCGIをインストールする
    インターネット インフォメーション サービス>World Wide Web サービス>アプリケーション開発機能>CGI
  2. ここからWebPIをダウンロード&インストールする
    https://www.microsoft.com/web/downloads/platform.aspx
  3. スタートメニューから「Microsoft Web Platform Installer」を実行
  4. フレームワーク→PHP7.4.13(x64) For IIS Express を追加してインストール
  5. 管理者モードのコマンドプロンプトで以下コマンドを実行して設定
    https://www.php.net/manual/ja/install.windows.manual.php
    を参考に、
    1. HTML内のPHPも動くように改変
    2. phppathにスペースが含まれていることに注意して、引数に適宜””を追加
@echo off

REM download .ZIP file of PHP build from http://windows.php.net/downloads/

REM path to directory you decompressed PHP .ZIP file into (no trailing \)
set phppath=C:\Program Files\iis express\PHP\v7.4


REM Clear current PHP handlers
%windir%\system32\inetsrv\appcmd clear config /section:system.webServer/fastCGI
REM The following command will generate an error message if PHP is not installed. This can be ignored.
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHPinHTML_via_FastCGI']

REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI "/+[fullPath='%phppath%\php-cgi.exe']"
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers "/+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='%phppath%\php-cgi.exe',resourceType='Unspecified']"
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers "/+[name='PHPinHTML_via_FastCGI',path='*.html',verb='*',modules='FastCgiModule',scriptProcessor='%phppath%\php-cgi.exe',resourceType='Unspecified']"
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script

REM Configure FastCGI Variables
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi "/[fullPath='%phppath%\php-cgi.exe'].instanceMaxRequests:10000"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHPRC',value='%phppath%\php.ini']"@echo off

REM download .ZIP file of PHP build from http://windows.php.net/downloads/

REM path to directory you decompressed PHP .ZIP file into (no trailing \)
set phppath=C:\Program Files\iis express\PHP\v7.4


REM Clear current PHP handlers
%windir%\system32\inetsrv\appcmd clear config /section:system.webServer/fastCGI
REM The following command will generate an error message if PHP is not installed. This can be ignored.
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']

REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI "/+[fullPath='%phppath%\php-cgi.exe']"
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers "/+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='%phppath%\php-cgi.exe',resourceType='Unspecified']"
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script

REM Configure FastCGI Variables
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi "/[fullPath='%phppath%\php-cgi.exe'].instanceMaxRequests:10000"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHPRC',value='%phppath%\php.ini']"


カテゴリー PHP