IIS7+PHP 一键配置脚本

这是一个用于在IIS7环境下配置PHP7.x的批处理脚本,包括下载PHP ZIP文件,清除现有PHP处理器,设置PHP FastCGI处理程序,监控php.ini变化,开启目录浏览和设置默认首页。此脚本适用于开发环境,生产环境可能需要调整部分设置。
摘要由CSDN通过智能技术生成
@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'].maxInstances:20
%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 为索引默认首页

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值