標籤:iis7 appcmd
1 添加應用程式進城池
appcmd.exe add apppool /name:test.com /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
2 添加網站,指定網站名,綁定,實體路徑
appcmd.exe add site /name:"test.com" /id:1 /bindings:http/*:81: /physicalpath:"E:\webroot\test.com\Web"
3 指定網站的進城池
appcmd.exe set site /site.name:"test.com" /[path=‘/‘].applicationPool:test.com
4 指定網站的預設文件為index.aspx
appcmd.exe set config "test.com/" /section:defaultDocument /+files.[@start,value=‘index.aspx‘] /commit:"test.com"
5 把特定目錄的指令碼執行許可權關閉
appcmd set config "test.com/Download" /section:handlers /accessPolicy:Read
6匯出一個機器上的所有應用進程池
%windir%/system32/inetsrv/appcmd list apppool /config /xml > c:/apppools.xml
7 匯出1個機器上的所有網站
%windir%/system32/inetsrv/appcmd list site /config /xml > c:/sites.xml
8 匯入所有進程池
%windir%/system32/inetsrv/appcmd add apppool /in < c:/apppools.xml
9 匯入所有網站
%windir%/system32/inetsrv/appcmd add site /in < c:/sites.xml
以下是批處理指令碼
10 給網站檔案授權
ICACLS e:\webroot\test.com\ /inheritance:e /grant:R "IIS AppPool\test.com":R
ICACLS e:\webroot\test.com\* /inheritance:e /grant:R "IIS AppPool\test.com":R
ICACLS e:\webroot\test.com\download /grant:M "IIS AppPool\test.com":R
ICACLS e:\webroot\test.com\download\* /grant:M "IIS AppPool\test.com":R
*******************************************************set Sitename=test.comset SitePath=E:\webroot\test.comset LogPath=G:\logfileset defaultDocument=‘index.aspx‘set Is32BitApp =Falseset BackPort=99set netversion=v4.0set Cache=Cache%windir%\system32\inetsrv\Appcmd add apppool /name:%Sitename% /managedRuntimeVersion:%netversion% /managedPipelineMode:"Integrated" /enable32BitAppOnWin64:False%windir%\system32\inetsrv\Appcmd add site /name:"%Sitename%" /id:100 /bindings:http/*:%BackPort%:,http/*:80:%sitename% /physicalpath:%SitePath% /logfile.directory:%LogPath%%windir%\system32\inetsrv\Appcmd set site /site.name:"%Sitename%" /[path=‘/‘].applicationPool:%Sitename%%windir%\system32\inetsrv\Appcmd set config "%Sitename%/" /section:defaultDocument /+files.[@start,value=%defaultDocument%] /commit:"%Sitename%"ICACLS %SitePath% /inheritance:e /grant:R "IIS AppPool\%SiteName%":RICACLS %SitePath%\* /inheritance:e /grant:R "IIS AppPool\%SiteName%":RICACLS %SitePath%\%Cache% /inheritance:e /grant:R "IIS AppPool\%SiteName%":RICACLS %SitePath%\%Cache% /inheritance:e /grant:R "IIS AppPool\%SiteName%":R
本文出自 “skybug” 部落格,請務必保留此出處http://skybug.blog.51cto.com/132577/1592050
IIS7.5 APPCMD 簡單用法及樣本