Move IIS inetpub Directory

To keep your operating system completely separate from all the web stuff, it is advisable to move inetpub directory off the root of a
%SystemDrive% to a completly different drive.

In these sample I am moving IIS from C:\inetpub to x:\inetpub.   Adjust this to your needs.

Steps described here were tested on Windows 7 IIS 7.5 and Windows 2008 Server R2 IIS 7.5.

Check if your http://localhost/ is working before proceeding.

 

-01- Stop all IIS-related services

Stop services related to IIS:

– FTP (if installed)
– IIS Admin
– SMTP (if installed)
– Windows Process Activation (will stop all other IIS services)
– WWW (will be stopped by stopping previous service)

 

-02- Move the Entire inetpub Directory

You would need to take ownership for couple of files away from from NT Service\TrustedInstaller.
On Windows 7 I even had to reboot into a parallel install and take ownership for two files to be able to move the folder.   On Windows 2008 Server R2 no restart was necessary.

 

-03- Make Required  Registry Modifications

For x32 machines you only need these two:


REG ADD HKLM\SOFTWARE\Microsoft\InetStp /v PathWWWRoot /t REG_EXPAND_SZ /d X:\inetpub\wwwroot /f
REG ADD HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d X:\inetpub\temp\appPools /f

For x64 systems one additional modification is needed:


REG ADD HKLM\SOFTWARE\Wow6432Node\Microsoft\InetStp /v PathWWWRoot /t REG_EXPAND_SZ /d X:\inetpub\wwwroot /f

 

-04- Make Modifications to IIS Configuration File

First backup file applicationHost.config in %WinDir%\System32\inetsrv\config\ directory, and only then proceed.

Open file in Notepad:

notepad %WinDir%\System32\inetsrv\config\applicationHost.config

in Notepad.  Here you search for %SystemDrive%\inetpub and replace with your new inetpub location string.

This method allows you to make changes to existing settings.  But now we need to add a new setting, because default values are no longer valid. To do that, we will use a different approach:

%windir%\system32\inetsrv\appcmd set config -section:system.applicationhost/configHistory -path:X:\inetpub\history

 

 

 

-05- Restart IIS Services and Test

Note that Windows Process Activation service must start for WWW Service to start.

Test and see, if  http://localhost/ is still works.

You are done.  Please ignore old sections bellow this point.

 

 

 

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

-0X- Modify IIS Meta Database (Please ignore – no longer required)

Make meta-database modifications from admin elevated command prompt.  This step relies on a script file adsutil.vbs that is only installed, if you add IIS 6 Compatibility Feature.

Values in IIS meta-database are arranged in a series of sub-folders.    Command adsutil.vbs ENUM allows to list all sub-folders and all the values at a given level.

List all the values that you might need to update in each directory before updating:
cscript X:\inetpub\adminscripts\adsutil.vbs ENUM
cscript X:\inetpub\adminscripts\adsutil.vbs ENUM /W3SVC
cscript X:\inetpub\adminscripts\adsutil.vbs ENUM /W3SVC/1/ROOT

Start updating found values. On my system 3 entries require an update : -01- AspDiskTemplateCacheDirectory, -02- LogFileDirectory and -03- path.
cscript X:\inetpub\adminscripts\adsutil.vbs set w3svc/AspDiskTemplateCacheDirectory “X:\inetpub\temp\ASP Compiled Templates”
cscript X:\inetpub\adminscripts\adsutil.vbs set w3svc/LogFileDirectory “X:\inetpub\logs\LogFiles”
cscript X:\inetpub\adminscripts\adsutil.vbs set w3svc/1/root/path “X:\inetpub\wwwroot”

Note that your entries could be different, if you renamed your default site or assigned it a different ID.  You will have more entries to update,  if you have several sites defined prior to inetpub movement.

(Visited 551 times, 4 visits today)

4 Comments

Your question, correction or clarification Ваш вопрос, поправка или уточнение

Editor on duty will review your comment. Can't wait? Discuss your topic right now in forums, if you register and login.     Required fields are marked with * Ваше послание пойдет на просмотр в редакцию. Не можете ждать? Обсудите ваш вопрос прямо сейчас в форуме Русский Круг , ecли вы зарегистрируетесь и войдёте под своим именем.     Поля, обязательные для заполнения, помечены *
* *