-
所需要工具:appcmd.exe 此工具不需要單獨(dú)安裝,與iis一起安裝的。此工具所在目錄“C:windowsSystem32inetsrv”
官方幫助文檔 -
appcmd.exe部署iis文站點(diǎn)示例:(復(fù)制此代碼保存為bat文件就能執(zhí)行使用)
推薦(免費(fèi)):IIS
::跳到iis命令工具所在目錄下 cd C:WindowsSystem32inetsrv ::刪除指定web站點(diǎn) appcmd.exe delete site "Default Web Site" appcmd.exe delete site "ppsweb" ::刪除指定應(yīng)用程序池 appcmd delete apppool "ppsweb" appcmd delete apppool "ppswebservice" appcmd delete apppool "ChartPic" appcmd delete apppool "PipelinePath" ::添加應(yīng)用程序池 appcmd add apppool /name:"ppsweb" ::修改應(yīng)用程序池啟動模式 appcmd.exe set APPPOOL "ppsweb" /config /startMode:"AlwaysRunning" /commit:apphost ::修改應(yīng)用程序池標(biāo)示 appcmd.exe set APPPOOL "ppsweb" /processModel.identityType:"SpecificUser" /processModel.userName:"*****" /processModel.password:"*****" /commit:apphost ::設(shè)置固定時間間隔回收應(yīng)用程序池 appcmd.exe set APPPOOL "ppsweb" /recycling.periodicRestart.time:"00:00:00" /commit:apphost ::設(shè)置指定時間回收應(yīng)用程序池 appcmd.exe set APPPOOL "ppsweb" /+"recycling.periodicRestart.schedule.[value='00:30:00']" /commit:apphost ::關(guān)閉快速故障防護(hù)功能 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站點(diǎn) 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站點(diǎn)默認(rèn)運(yùn)行路徑和應(yīng)用程序池 appcmd.exe set config -section:system.applicationHost/sites /+"[name='ppsweb',id='2',serverAutoStart='True'].[path='/',applicationPool='ppsweb',serviceAutoStartEnabled='True',preloadEnabled='True']" /commit:apphost ::添加web站點(diǎn)的應(yīng)程序路徑 appcmd.exe set config -section:system.applicationHost/sites /+"[name='ppsweb',id='2',serverAutoStart='True'].[path='/',applicationPool='ppsweb',serviceAutoStartEnabled='True',preloadEnabled='True'].[path='/',physicalPath='C:inetpubwwwrootppsweb']" /commit:apphost ::添加web子站點(diǎn)方式 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:inetpubwwwrootppswebWebService']" /commit:apphost ::修改web站點(diǎn)單個請求的大小 appcmd.exe set config -section:system.webServer/asp /limits.maxRequestEntityAllowed:"20000000" /commit:apphost ::修改web站點(diǎn)允許上傳單個文件大小 appcmd.exe set config -section:system.webServer/serverRuntime /uploadReadAheadSize:"20971520" /commit:apphost pause
3、使用工具自動生成iis命令部署腳本:(此處只給講解工具的使用,不詳細(xì)講解每一個屬性什么意思,這個自己去查文檔研究)
打開 《配置編輯器》
這個節(jié)點(diǎn)內(nèi)容較多,自己選擇需要配置節(jié)點(diǎn)。幫助文檔
這就是生成的腳本,有多種語言腳本(C#、JavaScript、APPCmd、PowerShell),在這里我比較熟悉AppCmd命令行,所以我選擇命令行腳本,你也可以選擇其他語言腳本,看你對哪個語言腳本熟悉就選擇哪個。
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載。
THE END