I want to make a dev, demo1, demo2 copy of the iis website I'm working on. I need each iis to run off its own code base, but the se开发者_开发技巧ttings will be almost identical. Is there an easy way in windows 7 ultimate to clone my dev iis to a new site without having to completely reconfigure it? To configure the virtual directories for each iis takes 20 mins plus so this could save me a lot of work.
Take a look at the ApplicationHost.config file. It should be located under "c:\windows\system32\inetsrv\config". This is an XML file that contains all of the IIS configuration data. You can manually modify this file to quickly create copies of your website. Just make sure to make a backup first in case you have problems.
Go to C:\Windows\system32\inetsrv\config
Make a copy of ApplicationHost.config
file. It's and XML file. Open it and go to <configuration><system.applicationHost><sites>
('configuration\system.applicationHost\sites
') find the site that you want to get duplicated (It will have same name as in IIS Management studio) then copy that site section and paste it below inside <sites>
then assign new site section new id and name attributes that have not been used yet name="Test1" id="5"
.
<site name="Test" id="4" serverAutoStart="true">
<application path="/" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OnTheMove\tags\Release 2.1.7.7\Offline\OfflineRouteHandler" userName="administrator" password="[enc:AesProvider:K0YvJ9r+XXNP8VUrZlbCPQ==:enc]" />
</application>
<application path="/Offline_Tablet" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTM\Offline\OnTheMoveOffline" userName="administrator" password="[enc:AesProvider:tT9uIWQDtIZTRnSMmx8XmIQv0lr7AbUXcuGby5qRZSo=:enc]" />
</application>
<application path="/OnTheMoveWebFiles" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTM\Offline\OnTheMoveOffline\OnTheMoveWebFiles" userName="administrator" password="[enc:AesProvider:zZgL59H6ka6jehb9BPTaNR8ogdgc8S90c3vf8p6MjPc=:enc]" />
</application>
<application path="/eai_enu" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTM\Offline\OfflineRouteHandler" userName="administrator" password="[enc:AesProvider:MfaNJz14gaJK5EjgIqhj4w==:enc]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
would get cloned to.
<site name="Test1" id="5" serverAutoStart="true">
<application path="/" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OnTheMove\tags\Release 2.1.7.7\Offline\OfflineRouteHandler" userName="administrator" password="[enc:AesProvider:K0YvJ9r+XXNP8VUrZlbCPQ==:enc]" />
</application>
<application path="/Offline_Tablet" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTMTrunk\Offline\OnTheMoveOffline" userName="administrator" password="[enc:AesProvider:tT9uIWQDtIZTRnSMmx8XmIQv0lr7AbUXcuGby5qRZSo=:enc]" />
</application>
<application path="/OnTheMoveWebFiles" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTMTrunk\Offline\OnTheMoveOffline\OnTheMoveWebFiles" userName="administrator" password="[enc:AesProvider:zZgL59H6ka6jehb9BPTaNR8ogdgc8S90c3vf8p6MjPc=:enc]" />
</application>
<application path="/eai_enu" applicationPool="Test">
<virtualDirectory path="/" physicalPath="C:\OTMTrunk\Offline\OfflineRouteHandler" userName="administrator" password="[enc:AesProvider:MfaNJz14gaJK5EjgIqhj4w==:enc]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
Go to IIS Management studio and if you did everything right there will be new web site that is stopped.
If it fails use backup copy to overwrite
ApplicationHost.config
.
UPDATE: As per comments if you are using 64bit environment when editing ApplicationHost.config
you want to use 64bit editor in Admin mode, Notepad is one.
Taken from here
Hope this saves you some time.
Actually the answer above - editing the ApplicationHost.config is only half off the job. You will also need to add the new AppPools to the applicationPools node.
Therefore :
1/. As others have mentioned first make a copy of your ApplicationHost.config file !! I usually copy and rename as "ApplicationHost_BACKUP_YYYY_MM_DD.config"
2/. Using Notepad (best option for Windows to mitigate issues with 32 bit vs 64 bit). Search for the site to be copied looking for (in my case) 'id="13"'. Once you find the site you want to copy. Copy the entire node and paste it after the site node copied. Assign it a new ID. Be sure to check sites in IIS for all used IDs first !! Also be sure to give it a new NAME and update all PATHS and APPPOOLS in the copied section. See example below.
SITE TO COPY (CURRENT) :
<site name="Reading List" id="13" serverAutoStart="true">
<application path="/" applicationPool="Reading List">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\reading_list\http" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:readinglist.jsgroup.local" />
</bindings>
</site>
COPIED SITE (NEW) :
<site name="Reading List" id="14" serverAutoStart="true">
<application path="/" applicationPool="Reading List 2">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\reading_list_2\http" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:readinglist2.jsgroup.local" />
</bindings>
</site>
3/. Add new Apppools to the applicationPools node as configured in your copied site above i.e. below I have copied the "Reading List" apppool and renamed the copy "Reading List 2"
<applicationPools>
<add name="DefaultAppPool" autoStart="true" managedRuntimeVersion="v4.0">
<processModel identityType="ApplicationPoolIdentity" />
</add>
<add name="Reading List" autoStart="true" managedRuntimeVersion="v4.0" />
<add name="Reading List 2" autoStart="true" managedRuntimeVersion="v4.0" />
<!-- Other AppPools here -->
</applicationPools>
If all is well, view site in IIS and restart if need be :-)
Hope that helps someone.
Richard Hetherington
How about copying the website using adsutil.vbs?
C:\Inetpub\AdminScripts> adsutil.vbs copy <source> <destination>
for example
C:\Inetpub\AdminScripts> adsutil.vbs copy w3svc/1 w3svc/556
The reason for the w3svc/
notation is more obvious if you execute adsutil.vbs ENUM /P W3SVC
first.
References:
- http://randomtype.ca/blog/how-to-create-multiple-websites-in-iis6-on-windows-xp/
- http://blogs.iis.net/rakkimk/archive/2008/11/20/adsutil-vbs-copying-a-website.aspx
精彩评论