2011-10-04 29 views
6

100'den fazla etki alanını yeni bir sunucuya taşıma sürecindeyiz. Basit bir BAT dosyası kullanarak IIS 7'ye bir Web sitesi girişi ve FTP girişi eklemeye izin verecek bir komut dosyası hazırladım. Çok iyi çalışan AppCmd ​​ADD SITE kullanarak çeşitli dersler buldum. Çalışarak :: c: \ scripts \ createIIS.bat youdomainname.com. Herhangi bir geri bildirim? - Çalışıyor.Web sitesi ve FTP'yi IIS 7'ye komut dosyasıyla ekleme

@Echo off 
:: -------------------------------------------- 
:: Create IIS 7 Site Entry/FTP Site 
:: -------------------------------------------- 

:: Get variable from command %1 Root Domain Name. 
set rootDomainName = %1 

:: This is the path to the Web Pages on the server. 
set WebFile=C:\websites\ 

:: ADD NEW Directory 
MKDIR %WebFile%%1 

:: ADD IIS ENTRY 
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/*:80:%1,http/*:80:www.%1 /physicalPath:C:\websites\%1 

:: -------------------------------------------- 
:: CREATE FTP in IIS 
:: -------------------------------------------- 
%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1" 


echo New Directory Created: %WebFile%%1 
echo IIS Website Created: %1 and www.%1 
echo FTP SITE Created: %1 
echo ... 
echo ... 
echo COMPLETED! 
pause 

cevap

5

Harika komut dosyası. Bu gerçekten bir soru olmasa da, toplu işlem için biraz değiştirdim.

Birincisi, sadece oluşturmak web sitelerine biraz değiştirilmiş toplu dosyasına başvuran eklemek için web sitelerinin bir metin dosyasında okuyan bir toplu iş dosyası, oluşturulan (hayır FTP en gerekli):

@Echo off 
:: --------------------------------------------------------------------------------------- 
:: Create Batched IIS 7 Site Entries 
:: 
:: Usage: CreateIISEntry.bat [websitename.com] (no www.) 
:: 

for /f %%X in (NewWebsiteEntries.txt) do CreateSingleIISEntry.bat %%X 


echo ... 
echo *** BATCH PROCESS HAS BEEN COMPLETED *** 

NewWebsiteEntries.txt içeriyor (. hiçbir www dahil) - web sitelerinin bir listesini oluşturmak için her satırda bir tane:

site1.com 
site2.com 
site3.com 

Son olarak, girdileri oluşturur toplu iş dosyası:

@Echo off 
:: --------------------------------------------------------------------------------------- 
:: Create IIS 7 Site Entry 
:: 
:: Usage: CreateSingleIISEntry.bat [websitename.com] (no www.) 
:: --------------------------------------------------------------------------------------- 

:: Get variable from command %1 Root Domain Name. 
set rootDomainName = %1 

:: This is the path to the Web Pages on the server. 
set WebFile=C:\inetpub\wwwroot\ 

:: ADD NEW Directory 
MKDIR %WebFile%%1 
echo New Directory Created: %WebFile%%1 

xcopy C:\inetpub\wwwroot\NewWebsiteHolding\*.* %WebFile%%1 

:: ADD IIS ENTRY 
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/[YOUR IP ADDRESS OR *]:80:%1,http/[YOUR IP ADDRESS OR *]:80:www.%1 /physicalPath:%WebFile%%1 
echo IIS Website Created: %1 and www.%1 

#:: -------------------------------------------- 
#:: CREATE FTP in IIS 
#:: -------------------------------------------- 
#%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1" 
# 
# 


#echo FTP SITE Created: %1 
echo ... 
echo ... 
echo New website added ========================= %1 

Benim durumumda, tüm yeni siteler bir kerede yayınlanmayacağından, içeriği yeni oluşturulan web sitesi dizinlerine kopyalanan varsayılan bir yer tutucu site.

Bu, tüm siteleri varsayılan uygulama havuzuna ekleyecektir.

Bu konuyla ilgili.

İlgili konular