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:
- ADDING A CHECK_MK AGENT IN WINDOWS HOST
- HOW TO INSTALL GIT BASH ON WINDOWS
- INSTALL MongoDB 3.2 ON WINDOWS
- HOW TO INSTALL IIS ON WINDOWS 8 & WINDOWS 10
- WINDOWS BATCH SCRIPT TO TAKE BACKUP OF SERVER EVENT LOG
- HOW TO INSTALL IIS ON WINDOWS SERVER 2012 R2 & WINDOWS SERVER 2016
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 http://windows.techoism.net website with document root C:\sites\windows.techoism.net
# appcmd add site /name:windows.techoism.net /bindings:http://*:80 /physicalpath:”C:\sites\windows.techoism.net”
Create Subdirectory Application:
You can also create the subdirectory application to your existing website. In other words If you want to configure URL like http://windows.techoism.net/blog then /blog is he subdirectory application. We are creating the document root for blog is c:\sites\blog.
# appcmd add app /site.name:windows.techoism.net /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 /site.name:windows.techoism.net /[path='/'].applicationPool:techpool
You can also change the Application Pool for a subdirectory URL use the following command.
# appcmd set site /site.name:windows.techoism.net /[path='/blog'].applicationPool:myAppPool
You can check your created WebSite/AppPool in the IIS manager also.
Enjoy it!