decorative banner

Creating virtual directories


    Creating a virtual directory differs by platform. Make sure your Web server software is installed and running before trying to create a virtual directory.

To create a virtual directory on Windows 98 or Windows ME running Personal Web server (PWS), or Windows 2000 or XP running IIS:

    Note: these servers support ASP and can support PHP if the appropriate plug-in is installed.

  1. Right-click the development folder containing your site's files, and choose Properties from the context menu.
  2. Click the Web Sharing tab.
  3. Click the Share This Folder radio button.
  4. In the Edit Alias dialog box, enter a name for the virtual directory. It can be the same as the name of your site.
  5. Make sure that the Read and Scripts access options are selected, and click OK.
  6. You may want to enable Directory Browsing. This allows you to view the folder from your browser and can be convenient when developing the site.
  7. Click OK to exit the Properties dialog box. The virtual directory is available in the server immediately.

To create a virtual directory on a Windows machine running IIS:

  1. Choose Start > Programs > Administrative Tools > Computer Management.
  2. Under Services and Applications, expand Internet Information Services.
  3. Select the default Web site, click the Action button, point to New, and select Virtual Directory.
  4. Follow the prompts in the New Virtual Directory Wizard, making sure the Read and Run Scripts options are selected. The virtual directory is available in the server immediately.

To create a virtual directory on a machine running Apache Web server software:

    Note: The Apache Web server uses the term alias instead of virtual directory.

  1. Locate the conf/httpd.conf file in the Apache install directory.
  2. Add an entry near the end of the file that looks like this. Be careful that it is not in the middle of some other entry:
  3. Alias /site_name "C:\pathname_to_site\your_site_directory"

    <Directory "C:\pathname_to_site\your_site_directory">

    Options Indexes FollowSymLinks MultiViews ExecCGI

    AllowOverride All

    Order allow,deny

    Allow from all

    </Directory>

  4. In the entry added in step 2, replace site_name with the alias for your site and replace C:\pathname_to_site\your_site_directory with the actual file path name to your site's root directory. If the server is running on Linux, the format of the path name would be a UNIX path name rather than the Windows-style pathname shown in the example.
  5. Restart the Apache server to have the change take effect.

To create a virtual directory on a machine running Tomcat Web server software:

    Note: The Tomcat Web server uses the term context instead of virtual directory.

  1. Locate the conf/server.xml file in the Tomcat install directory.
  2. Add the following entry in the part of the file where other similar entries are located. The server.xml file is an XML file, so be careful to place the addition at the proper location (nested within the <ContextManager> element tags and not to break any XML tags.
  3. <Context path="/site_name"

            docBase="C:\pathname_to_site\site_directory"

            debug="1"

            reloadable="true" >

    </Context>

  4. In the entry added in step 2, replace site_name with the alias for your site and replace C:\pathname_to_site\site_directory with the actual file path name to your site's root directory.
  5. Note: If you mis-edit the file or have unbalanced angle brackets or quotes, Tomcat cannot start properly. Watch for error messages when you start Tomcat.

  6. Stop and restart the Tomcat server (and the Apache server if you are running Tomcat under Apache) to have the change take effect.
  7. Note: Anytime you install new Java classes in the Tomcat context, you will have to stop and restart the Tomcat server.