使用批处理自动发布IIS站点,基于IIS7及以上

经过研究,终于使用批处理解决了站点发布步骤多的问题。

完整批处理如下:

@set "sitePath=%~dp0"

@echo 新建程序池
@C:\Windows\System32\inetsrv\appcmd.exe add apppool /name:"新程序池" /managedRuntimeVersion:"v4.0"
@C:\Windows\System32\inetsrv\appcmd.exe stop site "Default Web Site"
@C:\Windows\System32\inetsrv\appcmd.exe add site /name:"新站点" /bindings:http/*:80: /applicationDefaults.applicationPool:"新程序池" /physicalPath:%sitePath%

Pause

  

将上面的批处理代码保存成bat文件,放在要发布的网站文件夹的根目录下,右键,以管理员身份运行即可。

详解:

set "sitePath=%~dp0" 得到批处理文件所在目录,由于批处理文件放在网站跟目录下,所以即是得到网站的完整目录路径。
C:\Windows\System32\inetsrv\appcmd.exe add apppool /name:"新程序池" /managedRuntimeVersion:"v4.0"
新建程序池,不多说。

C:\Windows\System32\inetsrv\appcmd.exe stop site "Default Web Site"
停止默认站点,主要是我做的时候,要求默认站点停止掉,以让出80端口。可以根据自己需要是否要停止默认站点。

C:\Windows\System32\inetsrv\appcmd.exe add site /name:"新站点" /bindings:http/*:80: /applicationDefaults.applicationPool:"新程序池" /physicalPath:%sitePath%
新建站点,指定名称,
/bindings:访问地址及端口绑定。指定程序池。
/applicationDefaults.applicationPool:指定程序池
/physicalPath:指定网站文件目录。
大概就这么点了。反正不复杂,还可以指定更多的站点配置。相关的配置就请大家自行查找了。

转载于:https://www.cnblogs.com/nidongde/p/5198057.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值