Now let's take a look at some basic concepts and tasks associated with the WWW Publishing Service. We'll begin by examining the Default Web Site that is included as an example when you install Windows 2000 Server on a machine. Then we'll look at common tasks such as creating new Web sites and virtual directories and using Web sharing.
NOTE
Whether IIS was installed on your Windows 2000 Server during setup depends on how the installation was done. For example, if you upgraded a Windows NT 4 server that had a previous version of IIS installed on it, then Setup automatically upgrades these services to IIS 5. Otherwise, a default installation of Windows 2000 Server installs IIS and creates the Default Web Site, Default FTP Site, Administration Web Site, and Default SMTP Virtual Server, but not the Default NNTP Virtual Server.
In Figure 27-1 you saw an administrator's view of the Default Web Site—a series of sample configuration files whose default location on the server's local file system is C:\Inetpub\wwwroot, the root WWW publishing directory. The \Inetpub directory actually contains several important subdirectories, which are summarized in Table 27-1.
Note that some of these subdirectories will be present only if their related Windows 2000 optional components are installed on the server. Note also that you don't necessarily need to store Web site content in any of these directories—content can be located in any directory on the server, or on a network share located on some other server, as you'll soon see.
Table 27-1. IIS-related subdirectories located within the default C:\Inetpub directory
Subdirectory | Description |
---|---|
AdminScripts | Sample IIS administration scripts for the Windows Scripting Host. |
ftproot | Root directory of Default FTP Site. |
iissamples | Miscellaneous sample material. |
Remote administrator for the SMTP Service, using a Web browser. | |
mailroot | Various folders used by the SMTP Service. |
News | Remote administrator for the NNTP Service, using a Web browser. |
nntpfile | Various folders used by the NNTP Service. |
scripts | Default location for application scripts used by the Default Web Site. Includes samples and tools. |
wwwroot | Root directory of the Default Web Site. |
On the server, you can access the home page of the Default Web Site (Figure 27-2) in various ways by using a Web browser. Try out these methods:
When you attempt access from a remote machine on the connected network, you will see an "under construction" message, but that message actually tells you that the site is active and accessible. To connect, start Internet Explorer, press Ctrl+O to open the Open dialog box, enter any of the following, and then click OK:
Figure 27-2. The home page of the Default Web Site.
The Default Web Site is only one small example of how you can use the IIS 5 WWW Publishing Service. In fact, you can create as many different Web sites as you want using IIS 5, and you can host the content (pages, images, and other files) for these sites in a variety of locations. Each Web site acts as a separate entity, or virtual server; that is, it acts as if it were running on its own Windows 2000 Server and using the full resources available to it on that server. To illustrate this, let's create a new Web site on the server ws1, create a simple home page for it, and then test it by connecting to it from another machine on the network.
Before using the Web Site Creation Wizard to create a new Web site, you must decide how to name this site on the network. As you saw previously, when you use a Web browser like Internet Explorer to connect to a Web site and view its home page, you can specify the URL of the site in a variety of ways, including using the site's IP address, NetBIOS name, or fully qualified DNS name.
For this example, you'll bind a second IP address to the network interface card (NIC) on the Windows 2000 Server ws1 and establish a mapping between the new Web site you'll create and the new IP address you'll add. (Other ways to distinguish different Web sites on the same server are discussed in the section "Web Site Identification" in Chapter 28.) To add a second IP address, follow these steps:
Figure 27-3. Adding additional IP addresses for Web site identities.
Two more steps are required prior to creating the site. First, establish a new directory, C:\scribesweb, on the local server, which will store the content for the new site. Then create a simple home page called Default.htm within this site, using basic HTML. If you aren't familiar with HTML, enter the following text into NotePad and save the file in the \scribesweb directory as Default.htm, ensuring that your editor does not add a.TXT extension:
<HTML> <HEAD><TITLE>Scribes Ltd.</TITLE></HEAD> <BODY> <H1>Welcome to Scribes Ltd.</H1> <HR> This site is under construction! </BODY> </HTML> |
Now create a new Web site called Scribes Ltd. (named after the domain name Scribes.com) by following these steps:
Figure 27-4. The first screen of the Web Site Creation Wizard.
Figure 27-5. The IP Address And Port Settings screen of the Web Site Creation Wizard.
Figure 27-6. The new Scribes Ltd. Web site.
To test the IP address mapping (Web site identity) for the new Web site, go to a different machine on the network, start Internet Explorer, and open the URL http://172.16.11.203, which specifies the new Web site using its associated IP address. The page Default.htm should load in the browser window (Figure 27-7). Note that if a name server mapped this IP address to a DNS name like www.scribes.com, you could access the Web site by using http://www.scribes.com instead of by using the IP address.
Figure 27-7. Testing the new Scribes Ltd. Web site from a remote machine.
As a further test, try opening the following URLs from the same machine:
Each of these URLs specifies an identity for the Default Web Site on the server ws1 and should open the "under construction" home page for this site. We'll look more at Web site identities in Chapter 28.
In the previous example you created a new Web site called Scribes Ltd. whose content was located in the home directory C:\scribesweb on server ws1. To access content in this directory, you can use either of the following URLs:
Taking the first URL, you can associate or map a particular URL with the Web content stored in the site's home directory as represented here:
C:\scribesweb <—> http://172.16.11.203.
But what if you want to locate content for this Web site in a variety of locations and not just in the \scribesweb directory on the server? You can do this by using something called a virtual directory. A virtual directory is a way of mapping an alias (a portion of a URL) to a physical directory containing additional Web site content not located in the home directory for the site.
For example, let's say we want to store additional content in the directory C:\salesstuff on the local server and associate it with the virtual directory /sales. Note that the virtual directory uses a forward slash (/) instead of a backslash (\). The URL-to-directory mapping would be
C:\salesstuff <—> http://172.16.11.203/sales
Note that from the point of view of the client using the Web browser, the /sales content appears as a subdirectory of the home directory for the Scribes Ltd. Web site. In other words, the content virtually appears as a subdirectory of the home directory http://172.16.11.203. But in fact, the content is physically located in an entirely separate part of the directory tree on the server's file system (instead of being located in \scribesweb\sales, as you might expect from the URL). Virtual directories thus enable a kind of virtual file system specified by URLs that bears no direct relationship to the actual location of Web content for the site.
The content that is mapped to the alias representing a virtual directory can be located in one of two places, resulting in two different kinds of virtual directories:
Now let's use the Virtual Directory Creation Wizard to create a remote virtual directory for the new Scribes Ltd. Web site. Before running the wizard, you must perform two tasks:
CAUTION
Never use an administrator account for controlling access to a remote virtual directory, because this could result in a security breach.
Now create a new remote virtual directory called /sales within the Scribes Ltd. Web site, by following these steps:
Figure 27-8. The Web Site Content Directory screen of the Virtual Directory Creation Wizard.
If you now examine the Scribes Ltd. node in the Internet Information Services console tree, you'll notice a new node beneath it representing the new virtual directory (Figure 27-9). Try viewing the Default.htm page in this virtual directory by accessing the URL http://172.16.11.203/sales from a Web browser on a remote machine.
Figure 27-9. The /sales virtual directory within the Scribes Ltd. Web site.
Another way to create a new virtual directory is to use what's called Web sharing. For example, say you have the directory C:\Testing located on the local Web server ws1 and you want to share this directory as a virtual directory of the Default Web Site. To do this, follow these steps:
Figure 27-10. The Edit Alias dialog box.
Virtual directories can be confusing for a couple of reasons. First, there are two different icons you can use for nodes representing virtual directories in the IIS console. Second, physical directories can behave like virtual directories if they're physically located as subdirectories of the home directory or another virtual directory. Take a look at Figure 27-11 as an example. Looking at the various subnodes under the Scribes Ltd. node in the console tree, notice that
Figure 27-11. Confusion between virtual and physical directories.