Create a new Web server and a default site for configuration testing.
Buried deep within your Microsoft Server (versions 2008, 2008 R2 and 2012) is the most powerful Web server available. It’s just waiting for you to unleash its full potential. Whether your goal is to run a WordPress site from home or deploy and manage a large-scale, highly available Web farm for your company, IIS is up to the task.
To get started with IIS, you should have a “practice” server. This should be one you can trash over and over again without worrying about the consequences. It should be on its own network, safely isolated from your production environment. You can use Windows 8 on your laptop, but you should consider using a virtual machine (VM) for your testing. Use Hyper-V or even a simple VM on Windows Azure.
In this and successive articles, I’ll be using Windows Server 2012 with IIS 8. You can also use Windows 2008 or 2008 R2 (I’ll point out any important differences along the way). You should set up your VM as a domain controller with DNS. You’ll also want to make sure to have Windows PowerShell version 3 installed on your VM. If you haven’t started using Windows PowerShell, now would be a good time.
IIS is easy to install with the Server Manager graphical application. Select the Web Server role, and don’t add any additional features yet (I’ll explore those later). In a production environment, you shouldn’t add anything more than what you need for security reasons. For now, you’ll need only the minimum IIS install.
If you want to speed up the process and use Windows PowerShell, open an administrative Windows PowerShell console and type:
PS C:\> Install-WindowsFeature –Name Web-Server –IncludeManagementTools
Now I’ll discuss the changes that happen to the server during the installation. When IIS is installed, there are a few new additions to your server. There are five major changes you need to be aware of when working with IIS.
Figure 1 The Start Page of the IIS Manager.
Figure 2 Use Internet Information Services (IIS) Manager to manage a server or Web site.
Figure 3 There are a few file system additions after IIS installation.
There are three new services added that run under IIS. You’ll find them listed in the Services Manager under Administrative Tools or by using the Windows PowerShell Get-Service cmdlet:
These services play a huge role in understanding how IIS works. For now, it’s sufficient to check that these services are running. Use the following Windows PowerShell command to do so:
PS C:\> Get-Service –Name AppHostSVC, W3SVC, WAS
PS C:\> Get-Module -ListAvailable
PS C:\> Import-Module –Name WebAdministration
PS C:\> Get-Help *Web*
PS C:\> Get-Command –Module WebAdministration
PS C:\> Get-ChildItem -Path IIS:
Think of a Web server and the sites it hosts as a run-of-the-mill file server with network shares. With a file server, you share a directory off the file system, and give it a share name and permissions files to the directory for your users. When a user wants to open or use one of the files, he can type the UNC (\\ComputerName\ShareName) into an application such as File Explorer and open the files.
A Web server works the same way. You create a directory on the file system, add your files (Web pages) to the directory, and create a Web site to share those pages to the world. A Web site gets its “Share name” from something called a “binding” that’s configured for that Web site.
The IIS installation process creates the default Web site for you. It also creates a new directory, C:\inetpub\wwwroot, and adds a handful of basic files (Web pages). The Web site named “Default Web Site” is created with a binding of “*:80 (http).” This means any HTTP request to port 80 will be directed to the Default Web Site. You can view this information in the IIS Manager. You could also use Windows PowerShell (see Figure 4).
Figure 4 Viewing the settings of Default Web Site.
There are two ways to view information about the default Web site—or any other Web site, for that matter—using Windows PowerShell. They are the Get-Website cmdlet and the IIS: provider method:
PS C:\> Get-Website –Name 'Default Web Site'
PS C:\> Get-Childitem –Path IIS:\Sites
The IIS: provider method is preferable because you can also get a quick list of the all the files and additional Web site components by adding the Web site name to the path:
PS C:\>Get-ChildItem –Path 'IIS:\Sites\Default web site'
The default Web site is good to have around for testing, so don’t delete it. It’s a great way to check that the Web server is working and receiving HTTP requests. To test the default Web site, open a browser and type the site name. In this case, the binding is for all port 80 requests, so here’s the URL:
Because port 80 is a default in your browser, you don’t need to type that—but doing so will help you see that a URL contains the server name and the share name (Web site binding), just like a UNC.
Want to change your default Web page to something else? Open Notepad.exe and type “TechNet Rocks!” and save the file to C:\inetpub\wwwroot as Default.htm (you could also try it this way with Windows PowerShell):
PS C:\> Add-Content -Path C:\inetpub\wwwroot\Default.htm -Value "TechNet Rocks!"
Open your browser and type the URL for the default Web site or with Windows PowerShell:
PS C:\> Start iexplore http://<servername>
You now have your own Web page on your own Web server. Now you’re probably starting to ask a lot of questions: “Can I move the default Web site? How do I create my own Web sites? How do I configure DNS for my Web site?” All these questions, plus many more, will be answered in forthcoming articles about IIS.
Jason Helmick is the director of Windows PowerShell technologies for Interface Technical Training, based in Phoenix, Ariz. He’s a speaker, author, teacher and inadvertent IIS administrator.