The good news is that if we're running Windows, we can install a "personal" version of Microsoft's Internet Information Server (IIS) for free. Indeed with Windows 2000 and XP, it is already available on the CD; we just need to install it. The downside is that, while the version of IIS that comes with the non-server versions of Windows is fine for internal intranet websites, it's definitely not suitable for high-use Internet websites because it's not robust or secure enough. However, it is great for developing server-side script before deploying it to the full Windows web server called Internet Information Services (IIS); this is supplied with Windows NT Server, Windows 2000 editions and Windows 2003 Server editions.
The steps needed to install a web server on Windows depend on which operating system is being used. Windows 2000 Server and Advanced Server users will already have IIS installed. If you're running Windows 2000 Professional, note that IIS comes with it, but is not installed by default. Instead, you'll need to go to Control Panel ® Add/Remove programs and select Add/Remove Windows Components, under which you'll find the option to install Internet Information Services (IIS).
Windows NT 4 Server and Workstation users will need to install the NT Option pack. For Server users, this installs the full IIS server version. Workstation users will have the IIS version installed. The NT Option pack can be obtained on CD and from the Microsoft website at the following URL:
Finally, Windows 98 and 98SE users will find IIS on the Windows disk. Note that IIS for Windows 9x is called Personal Web Server (PWS) and is even more cut down than the IIS that comes with Windows XP or 2000 Professional.
We'll look next at all the steps necessary to install IIS on a Windows 98 machine. Most of the steps are similar to those used with other versions of Windows, with just a few minor variations.
The setup files for IIS are on the Windows 98 CD in the directory \add-ons\IIS\.
We need to copy these files from the IIS directory on the CD to the local hard drive: The C:\Temp directory would be a good place.
Due to changes in Windows operating system one of the files, MtsSetup.dll, is out of date and needs to be replaced with one downloaded from the Microsoft website. This file can be downloaded from this URL:
Save the executable file to your hard drive in the C:\Temp directory, and then run it. First, the license agreement will appear. Read it. To accept it, click Yes to start the install. (See Figure 16-2.)
Next, in the text box that appears, enter or browse to the directory into which the IIS directory was copied from the CD, and click OK. (See Figure 16-3.)
A the box like that shown in Figure 16-4 may pop up asking if you want to overwrite the existing Mtssetup.dll file with the new one you just downloaded; just click Yes.
That completes the update. Now we can start the IIS installation process by running setup.exe in C:\Temp\IIS by clicking Run on the Start menu.
We should then see the screen shown in Figure 16-5.
Click the Next button and we'll be given a choice of whether we want a Minimum, Typical, or Custom install. Unless hard drive space is at a premium (that is, you have less than 50MB free) then go for the Typical install, which requires about 32MB of hard drive space. (See Figure 16-6.)
In the next screen, we are allowed to choose the directory where the web directories and web pages for the server will be stored, as shown in Figure 16-7. The default directory is fine unless you have limited space on your C drive, in which case any hard drive is acceptable. We're not given the option of selecting an FTP or application directory because the Windows 98 IIS does not support either of these. Once the directory is selected, click Next and the IIS installation will commence.
After the installation has finished, click Finish and restart the computer.
First open the Windows XP control panel by selecting Control Panel from the Start menu, as shown in Figure 16-8.
From the Control Panel as shown in Figure 16-9, select Add or Remove Programs.
When the Add/Remove programs dialog box appears, click the Add/Remove Windows components and shortly the dialog box shown Figure 16-10 will appear:
Scroll down till the Internet Information Services (IIS) checkbox is shown and then check it. Make sure to have the Windows XP install disk handy, then click Next and the screen in Figure 16-11 will most likely show asking us to insert the Windows XP disk:
Click OK and IIS (as IIS is known in XP) will be installed.
Web servers are a little different from normal programs. Normally, we load or start a program by clicking its icon. When we've stopped using it, we close it down. However, web servers usually start when the operating system starts, unless you specify otherwise. They run in the background and are termed a service rather than a normal program.
IIS comes with its own basic console, which gives us control over the web service. This can be found via the Administrative Tools in the Control Panel. Go to the Control Panel and select the Performance and Maintenance option. (See Figure 16-12.)
Now the screen in Figure 16-13 is shown. Click the link to Administrative Tools.
Finally, we will see the screen shown in Figure 16-14.
Double-click the Internet Information Services icon to open up the IIS control panel, shown in Figure 16-15.
You may want to add a desktop shortcut to the IIS console to save all these steps.
Open up the tree until you see Default Website and click it to see a list of the currently defined virtual websites and directories, as shown in Figure 16-16.
From within the console, we can change many properties relating to our default website. For example, if we want to stop the service, we right-click the default website in the tree and select Stop. To start it running again, do the same except we select the Start menu option. Note that when the service is stopped, any attempts to load web pages from the server will fail. The console also gives us the ability to create new web directories and check usage statistics, such as how many visitors per day have visited our site. Note that the Windows 98 version of IIS (called PWS) is much more basic and limited in the properties we can set. However, it allows us to do all we need to do for this book. The interface is just very different. Windows NT4 and 2000 users will see a very similar interface to the XP one.
The first question is, how do we load a web page from our local server? Well currently we don't have any pages specified so the default page will be opened when we access our web server. If we open IE and type http://localhost into a web browser on the same PC as the server, we'll see the screen in Figure 16-17. Note that other browsers won't work when accessing the default http://localhost/ when the browser is running on the same machine as the server. It's fine if the browser is on another machine on the network.
One browser window shows a welcome to IIS page and the other shows the IIS help files. Note that we can also access the server by typing http://computer_name where computer name is the name you gave to your PC. It's also shown at the top of the tree in the IIS console, just below Internet Information Services.
However if we were to browse our website from another PC on the Internet, we would see the default Under Construction page we get until we create our own pages and put them on the server. (See Figure 16-18.)
If we want to find out in which actual directory on our PC the server has put the web pages, we right-click Default Web Site in the console and select Properties, to see the Default Web Site Properties dialog box shown in Figure 16-19.
Now select the Home Directory tab, as shown in Figure 16-20.
We can see the local path text box shows us where the physical directory is on our PC. By default it is usually c:\inetpub\wwwroot, although we can change this if necessary. However, it is best to leave it at the default for now.
If we put a file in the root directory of our server called myPage.htm, typing the following into our browser will load the myPage.htm page.
http://myservername/myPage.htm
If we create a new directory under our root directory, C:\Inetpub\wwwroot, called myDir and put a file called myPage2.htm in there, typing the following into our web browser will cause myPage2.htm in myDir to be loaded.
http://myservername/myDir/myPage2.htm
If we look at the console, we'll notice that some of the directories listed have a little ball next to the normal yellow folder icon. This indicates they are virtual directories. So what are virtual directories?
Without virtual directories, any document that can be browsed to needs to be in a folder under the web server's root directory. However, virtual directories allow us to give a physical directory on the hard drive an alias name and then allow this physical directory to be accessible to users through the web server, without it being physically placed under the web server's root directory. This process is also called aliasing. The virtual directories are not real; they are just a way of referencing a physical directory.
Say, for example, that we want to create a directory C:\MyWeb sites\MyExampleDirectory and allow people to access its contents by typing one of the following addresses:
http://myservername/AWalkOnTheServerSide http://localhost/AWalkOnTheServerSide
To do this, we create a new virtual directory called AWalkOnTheServerSide. We can create a virtual directory in two ways. One way is to use the IIS console, and the other way is from Windows Explorer. Let's see how each works.
First, the IIS console method. Load the console and then make sure the default website and its folders are showing in the tree. Right-click the Default Web Site. Select New, and the Virtual Directory submenu shown in Figure 16-21 is displayed.
Selecting this menu will bring up the Virtual Directory Wizard, shown in Figure 16-22.
Click the Next button and we'll be asked to enter the alias of the virtual directory. In our case we want to call it "AWalkOnTheServerSide." (See Figure 16-23.)
Now click the Next button and we'll see the dialog box shown in Figure 16-24. In the figure, I've already typed in the name of an existing physical directory.
Click Next again and we'll see the penultimate part of the wizard, shown in Figure 16-25.
There are five check boxes to choose from. They specify the type of access that the directory will have on the web server. Read enables users to view the web pages by browsing to our website. Run Scripts (such as ASP) enables server-side scripts to run. Execute allows users to run programs in that directory. Write allows someone browsing our website to change the contents of files, and Browse allows someone to view a list of all the files on our website. For security reasons, it's normally best not to enable Execute, Write, or Browse permissions except possibly on a development server because on most occasions we don't want people browsing our website to be able to run any programs in our directory, change files, or see what files are on there.
Click the Next button and the final screen is displayed, as shown in Figure 16-26.
Click Finish and the virtual directory AWalkOnTheServerSide will be created and mapped to the physical directory C:\MyWeb sites\MyExampleDirectory. We refer to the physical directory as being web shared. It's now viewable with a web browser by people on other computers on the network.
The second method of creating virtual directories is from Windows Explorer.
Open Windows Explorer, and select and right-click the directory to be web shared and select Properties. For example, I'm going to web share my directory C:\MyWebSites\AnotherVirtualDirectory.
From the dialog box that pops up, as shown in Figure 16-27, select the Web Sharing tab.
In the form, change the radio button from Do not share this folder to Share this folder. A dialog box that allows us to set the same options we set in the wizard in IIS pops up so we can set the directory's alias or virtual name, and the permissions as under the IIS console. By default the name of the directory we right-clicked is shown as a suggested virtual directory name. (See Figure 16-28.) To use another name, such as AnotherWalkOnTheServerSide, just type that in instead.
That completes our look at IIS. It's time to start putting it to use with some server-side scripting.