@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:\xapp\apps\php
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='Either',requireAccess='Script']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script
REM directoryBrowse Switch
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/directoryBrowse -enabled:true
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 set config -section:system.webServer/fastCgi /[fullPath='%phppath%\php-cgi.exe'].monitorChangesTo:%phppath%\php.ini
%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']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/defaultDocument /+"files.add[value='index.php']"
pause
拷贝上述代码 , 保存到 名为 add_php_mod.bat 的文件,在你添加好 IIS7 环境的机器上运行他,运行完毕后,将 你 下载好的 php7.x 非线程安全的安装包里的内容解压到 代码 所设置的 php 引擎所安装的路径,并且配置好 php.ini 文件即可使用。
本脚本基于PHP官方手册,增加了三个配置项!
设置 目录浏览 为 开(开发环境,生产环境需关闭)
增加对 php.ini 文件变化的监控
添加 index.php 为索引默认首页
等
|