How to Create a WebSite/AppPool in IIS using Command Line

IIS is formerly known for “Internet Information Services.” IIS is a web server software created by Microsoft for windows server. As a system administrator, we know that to manage IIS is easy from GUI. A few times we get tasks to create a large number of websites under IIS or create a site in IIS. This article will help you in the best way to create a WebSite/AppPool in IIS using Command-Line.

Useful Article:

Before start creating the WebSite/AppPool, start the command prompt as administrator. So that you can privileges to execute all the commands. After that access below location in command prompt.

# cd c:\Windows\System32\inetsrv

Create Website in IIS:

Now, We are going to create a website using the command line. We are creating website with document root C:\sites\

# appcmd add site / /bindings:http://*:80 /physicalpath:”C:\sites\”

Create Subdirectory Application:

You can also create the subdirectory application to your existing website. In other words If you want to configure URL like then /blog is he subdirectory application. We are creating the document root for blog is c:\sites\blog.

# appcmd add app  / /path:/blog /physicalPath:C:\sites\blog

Create Application Pool in IIS:

An application pool fills in as a container for your applications in IIS. It’s a combination of at least one URLs that can be served by a worker process. IIS App Pool used for the gathering of sites to use similar configuration settings or prevent different applications to use resources of one application by different applications.

App Pool with Default Settings:

Use the following command to create Application Pool named “techpool” with default IIS settings.

# appcmd add apppool /name:techpool

App Pool with Specific Settings

If you want to use different settings for your App Pools, use mention command. Change managedRuntimeVersion as per your requirements v1.0, v1.1, v2.0 or v4.0.

# appcmd add apppool /name:myAppPool /managedRuntimeVersion:v4.0

Create Application Pool Credential

You can use mention command to configure the application pool with credentials. Here, we are using application pool named “techpool”, username “anuket” and password “redhat123?”

# appcmd set config /section:applicationPools /[name='techpool'].processModel.identityType:SpecificUser /[name='techpool'].processModel.userName:anuket /[name='techpool'].processModel.password:redhat123?

Assign/Change App Pool to an App:

You can likewise change the Application Pool of any site. Use the following command to change the application pool of the site.

# appcmd set site / /[path='/'].applicationPool:techpool

You can also change the Application Pool for a subdirectory URL use the following command.

# appcmd set site / /[path='/blog'].applicationPool:myAppPool

You can check your created WebSite/AppPool in the IIS manager also.

Enjoy it!

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.