找回密码
 立即注册

介绍IIS脚本自动化部署方式

2022-7-29 22:16:14 · 站长社区

221650t7kqukwivsaivcji.jpg


IIS脚本自动化部署方式

  1. 所需要工具:appcmd.exe 此工具不需要单独安装,与iis一起安装的。此工具所在目录“C:\Windows\System32\inetsrv”
    官方帮助文档

  2. appcmd.exe部署iis文站点示例:(复制此代码保存为bat文件就能执行使用)

推荐(免费):IIS

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

::跳到iis命令工具所在目录下

cd C:\Windows\System32\inetsrv

::删除指定web站点

appcmd.exe delete site Default Web Site

appcmd.exe delete site ppsweb

::删除指定应用程序池

appcmd delete apppool ppsweb

appcmd delete apppool ppswebservice

appcmd delete apppool ChartPic

appcmd delete apppool PipelinePath

 

::添加应用程序池

appcmd add apppool /name:ppsweb

::修改应用程序池启动模式

appcmd.exe set APPPOOL ppsweb /config /startMode:AlwaysRunning  /commit:apphost

::修改应用程序池标示

appcmd.exe set APPPOOL ppsweb /processModel.identityType:SpecificUser /processModel.userName:***** /processModel.password:*****  /commit:apphost

::设置固定时间间隔回收应用程序池

appcmd.exe set APPPOOL ppsweb /recycling.periodicRestart.time:00:00:00  /commit:apphost

::设置指定时间回收应用程序池

appcmd.exe set APPPOOL ppsweb /+recycling.periodicRestart.schedule.[value=00:30:00] /commit:apphost

::关闭快速故障防护功能

appcmd.exe set APPPOOL ppsweb /failure.rapidFailProtection:False  /commit:apphost

 

appcmd add apppool /name:ppswebservice

appcmd.exe set APPPOOL ppswebservice /config /startMode:AlwaysRunning  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /processModel.identityType:SpecificUser /processModel.userName:***** /processModel.password:*****  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /recycling.periodicRestart.time:00:00:00  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /+recycling.periodicRestart.schedule.[value=00:30:00] /commit:apphost

appcmd.exe set APPPOOL ppswebservice /failure.rapidFailProtection:False  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /enable32BitAppOnWin64:True  /commit:apphost

 

::添加web站点

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True] /commit:apphost

::绑定端口访问方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].bindings.[protocol=http,bindingInformation=*:80:] /commit:apphost

::绑定端口访问方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].bindings.[protocol=https,bindingInformation=*:443:] /commit:apphost

::添加web站点默认运行路径和应用程序池

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/,applicationPool=ppsweb,serviceAutoStartEnabled=True,preloadEnabled=True] /commit:apphost

::添加web站点的应程序路径

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/,applicationPool=ppsweb,serviceAutoStartEnabled=True,preloadEnabled=True].[path=/,physicalPath=C:\inetpub\wwwroot\ppsweb] /commit:apphost

::添加web子站点方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/WebService,applicationPool=ppswebservice,serviceAutoStartEnabled=True,preloadEnabled=True] /commit:apphost

 

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/WebService,applicationPool=ppswebservice,serviceAutoStartEnabled=True,preloadEnabled=True].[path=/,physicalPath=C:\inetpub\wwwroot\ppsweb\WebService] /commit:apphost

::修改web站点单个请求的大小

appcmd.exe set config  -section:system.webServer/asp /limits.maxRequestEntityAllowed:20000000  /commit:apphost

::修改web站点允许上传单个文件大小

appcmd.exe set config  -section:system.webServer/serverRuntime /uploadReadAheadSize:20971520  /commit:apphost

 

pause

3、使用工具自动生成iis命令部署脚本:(此处只给讲解工具的使用,不详细讲解每一个属性什么意思,这个自己去查文档研究)
打开 《配置编辑器》
221650yalnhudlw763t26t.png
这个节点内容较多,自己选择需要配置节点。帮助文档
221650vzwzlvndzvnr3x9m.png
这就是生成的脚本,有多种语言脚本(C#、javaScript、APPCmd、PowerShell),在这里我比较熟悉AppCmd命令行,所以我选择命令行脚本,你也可以选择其他语言脚本,看你对哪个语言脚本熟悉就选择哪个。
221650l456c3z3hcp3b39d.png


全部评论 0

221650t7kqukwivsaivcji.jpg


IIS脚本自动化部署方式

  1. 所需要工具:appcmd.exe 此工具不需要单独安装,与iis一起安装的。此工具所在目录“C:\Windows\System32\inetsrv”
    官方帮助文档

  2. appcmd.exe部署iis文站点示例:(复制此代码保存为bat文件就能执行使用)

推荐(免费):IIS

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

::跳到iis命令工具所在目录下

cd C:\Windows\System32\inetsrv

::删除指定web站点

appcmd.exe delete site Default Web Site

appcmd.exe delete site ppsweb

::删除指定应用程序池

appcmd delete apppool ppsweb

appcmd delete apppool ppswebservice

appcmd delete apppool ChartPic

appcmd delete apppool PipelinePath

 

::添加应用程序池

appcmd add apppool /name:ppsweb

::修改应用程序池启动模式

appcmd.exe set APPPOOL ppsweb /config /startMode:AlwaysRunning  /commit:apphost

::修改应用程序池标示

appcmd.exe set APPPOOL ppsweb /processModel.identityType:SpecificUser /processModel.userName:***** /processModel.password:*****  /commit:apphost

::设置固定时间间隔回收应用程序池

appcmd.exe set APPPOOL ppsweb /recycling.periodicRestart.time:00:00:00  /commit:apphost

::设置指定时间回收应用程序池

appcmd.exe set APPPOOL ppsweb /+recycling.periodicRestart.schedule.[value=00:30:00] /commit:apphost

::关闭快速故障防护功能

appcmd.exe set APPPOOL ppsweb /failure.rapidFailProtection:False  /commit:apphost

 

appcmd add apppool /name:ppswebservice

appcmd.exe set APPPOOL ppswebservice /config /startMode:AlwaysRunning  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /processModel.identityType:SpecificUser /processModel.userName:***** /processModel.password:*****  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /recycling.periodicRestart.time:00:00:00  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /+recycling.periodicRestart.schedule.[value=00:30:00] /commit:apphost

appcmd.exe set APPPOOL ppswebservice /failure.rapidFailProtection:False  /commit:apphost

appcmd.exe set APPPOOL ppswebservice /enable32BitAppOnWin64:True  /commit:apphost

 

::添加web站点

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True] /commit:apphost

::绑定端口访问方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].bindings.[protocol=http,bindingInformation=*:80:] /commit:apphost

::绑定端口访问方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].bindings.[protocol=https,bindingInformation=*:443:] /commit:apphost

::添加web站点默认运行路径和应用程序池

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/,applicationPool=ppsweb,serviceAutoStartEnabled=True,preloadEnabled=True] /commit:apphost

::添加web站点的应程序路径

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/,applicationPool=ppsweb,serviceAutoStartEnabled=True,preloadEnabled=True].[path=/,physicalPath=C:\inetpub\wwwroot\ppsweb] /commit:apphost

::添加web子站点方式

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/WebService,applicationPool=ppswebservice,serviceAutoStartEnabled=True,preloadEnabled=True] /commit:apphost

 

appcmd.exe set config  -section:system.applicationHost/sites /+[name=ppsweb,id=2,serverAutoStart=True].[path=/WebService,applicationPool=ppswebservice,serviceAutoStartEnabled=True,preloadEnabled=True].[path=/,physicalPath=C:\inetpub\wwwroot\ppsweb\WebService] /commit:apphost

::修改web站点单个请求的大小

appcmd.exe set config  -section:system.webServer/asp /limits.maxRequestEntityAllowed:20000000  /commit:apphost

::修改web站点允许上传单个文件大小

appcmd.exe set config  -section:system.webServer/serverRuntime /uploadReadAheadSize:20971520  /commit:apphost

 

pause

3、使用工具自动生成iis命令部署脚本:(此处只给讲解工具的使用,不详细讲解每一个属性什么意思,这个自己去查文档研究)
打开 《配置编辑器》
221650yalnhudlw763t26t.png
这个节点内容较多,自己选择需要配置节点。帮助文档
221650vzwzlvndzvnr3x9m.png
这就是生成的脚本,有多种语言脚本(C#、javaScript、APPCmd、PowerShell),在这里我比较熟悉AppCmd命令行,所以我选择命令行脚本,你也可以选择其他语言脚本,看你对哪个语言脚本熟悉就选择哪个。
221650l456c3z3hcp3b39d.png


热门推荐
您需要登录后才可以回帖 立即登录
说说你的想法......
0
0
0
返回顶部