Internet Information Services (IIS) is a web server from Microsoft that is used to host websites and web applications. IIS comes pre-installed with Windows operating systems and provides a user-friendly interface for managing websites and web applications. However, for advanced users and administrators, IIS also provides the option to manage it using the command line interface, known as the Command Prompt.
In this article, we will guide you through the process of creating a website and application pool in IIS using the Command Prompt.
Step 1: Open Command Prompt
The first step in creating a website and application pool in IIS using the Command Prompt is to open the Command Prompt itself. To do this, press the Windows key + X and select the “Command Prompt (Admin)” option. If prompted, click “Yes” to grant administrative permissions.
You can also press the “WINDOW” button and then search for “Command Prompt”. In the search list, right-click on “Command Prompt” and click “Run as administrator”>
On the command prompt, navigate to the C:\Windows\System32\inetsrv directory.
Step 2: Install IIS
If IIS is not already installed on your system, you will need to install it. To do this, type the following command in the Command Prompt and press Enter:
dism /online /enable-feature /featurename:IIS-WebServer /all
Step 3: Create Application Pool in IIS
IIS App Pool is used for grouping sites to use similar configuration settings or prevent other applications to use resources of one application by other applications. Use one of the below options as per your requirements
- App Pool with Default Settings
Use the following command to create an Application Pool named “myAppPool” with default settings of IIS.
appcmd add apppool /name:MyAppPool
- App Pool with Specific Settings
If you want to use different settings for your App Pools, use the command below. Change managedRuntimeVersion as per your requirements v1.0, v1.1, v2.0 or v4.0.
appcmd add apppool /name:MyAppPool /managedRuntimeVersion:v2.0 /managedPipelineMode:Integrated
Step 4: Create a Website in IIS
Once the application pool is created, you can now create a website in IIS. To do this, use the following command:
appcmd add site /name:MyWebsite /physicalPath:C:\inetpub\wwwroot\MyWebsite /bindings:http/*:80:example.com /apppool:MyAppPool
Replace “MyWebsite” with the desired name for your website and “C:\inetpub\wwwroot\MyWebsite” with the physical path where the website’s files will be stored. Also, replace “example.com” with your site domain name.
Step 5: Start the Website
The final step is to start the website. Use the following command to start the website:
appcmd start site /site.name:MyWebsite
Replace “MyWebsite” with the name of your website.
Step 6: Create Subdirectory Application (If Required)
You can add a subdirectory application to your existing website. For example, to configure a URL like http://example.com/blog, the /blog is the subdirectory application configured under the example.com website. To create this create execute the following command. Assuming the document root for the blog is C:\inetpub\wwwroot\blog.
appcmd add app /site.name:example.com /path:/blog /physicalPath:C:\inetpub\wwwroot\blog
Step 7: Changing the Application Pool (If Required)
You can also change the Application Pool of any website using appcmd command. Use following command to change application pool of site example.com and set App Pool to myAppPool
appcmd set site /site.name:example.com /[path='/'].applicationPool:myAppPool
To change the Application Pool for a subdirectory URL use the following command.
appcmd set site /site.name:example.com /[path='/blog'].applicationPool:myAppPool
In conclusion, creating a website and application pool in IIS using the Command Prompt is a simple process that can be completed in just a few steps. This method is particularly useful for advanced users and administrators who want to automate the process of creating websites and application pools or for those who prefer to use the command line interface. By following the steps outlined in this article, you can easily create a website and application pool in IIS using the Command Prompt.