|

How to setup Apache as your personal web server under Windows
The most popular web server in the world is Apache.
Between Perl, MySQL and Apache (all three of which are open-source and free)
you can set up almost any site you can imagine. Most web hosting services use
Apache and if you want to take advantage of the administrative power of Apache
on your site, you'll have to install Apache for Windows to access and test your
site locally without making any changes to your cgi scripts.
That's right, the advanced user tosses out Microsoft's Personal Web Server
and uses Apache instead. The Apache Software Foundation warns that the Win32
version of its server software is not as stable or secure as its Unix version
but for purposes of testing a web site locally, it's fine.
Installation is easy. Download
the latest binary for Win32 and execute it. It'll create an Apache
Group under your Program Files. Choose Programs
> Apache Web Server > Management > Edit Configuration. This
opens a file called httpd.conf which is a text
file that holds all the important server directives. You customize the basic
functionality of Apache by editing this file.
Most of httpd.conf is self-explanatory. There
are plenty of comments, but there are a few stumbling blocks, so I'll guide
you through it.
First thing to do is set up your document root directory. You must use forward-slashes
instead of the normal back-slash under Windows. The examples below assume the
standard Dreamweaver setup. Your document root and other directories may be
different.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# replace
# DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs"
# with
DocumentRoot "C:/Sites/your_site"
...
#
# This should be changed to whatever you set DocumentRoot to.
#
# replace
# <directory "C:/Program Files/Apache Group/htdocs">
# with
<directory "C:/Sites/your_site">
Stumbling Block #1: If you want to use CGI scripts and SSI outside
of your designated script directory, you have to add ExecCGI
and Includes to this Options
line. This is not apparent the first time you're trying to figure out the file.
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks MultiViews ExecCGI Includes
If you want to use index.shtml (SSI) as the default
document of the directory.
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<ifmodule mod_dir.c>
DirectoryIndex index.shtml index.html
</ifmodule>
Uncomment the ScriptInterpreterSource line because
you'll want to use the registry to determine how to run your CGI scripts.
# uncomment
# ScriptInterpreterSource registry
# to
ScriptInterpreterSource registry
Under the Alias section, add an alias for /manual/
so that you can still reference the local offline docs.
#
# Aliases: Add here as many aliases as you need (with no limit).
# The format is Alias fakename realname
#
<ifmodule mod_alias.c>
...
# ADD THESE LINES SO THAT YOU CAN STILL READ THE APACHE
# DOCUMENTATION AFTER CHANGING YOUR DOCUMENT ROOT DIRECTORY
Alias /manual/ "C:/Program Files/Apache Group/Apache/htdocs/manual/"
<directory "C:/Program Files/Apache Group/htdocs/manual">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</directory>
# END OF LINES TO ADD
ScriptAlias defines where your script directory
resides. Modify it like you did the document root definition above.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to
# the client.
# The same rules about trailing "/" apply to ScriptAlias directives
# as to Alias.
#
# replace
# ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
# with
ScriptAlias /cgi-bin/ "D:/Sites/your_site/cgi-bin/"
#
# "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to
# whatever your ScriptAliased CGI directory exists,
# if you have that configured.
#
# replace
# <directory "C:/Program Files/Apache Group/cgi-bin">
# with
<directory "D:/Sites/your_site/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</directory>
Stumbling Block #2: You can't just uncomment the AddHandler
and AddType lines because they specify .cgi
and .shtml, when they should leave out the period.
You must remove the period.
#
# Document types.
#
<IfModule mod_mime.c>
...
#
# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into
# the server or added with the Action command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
# uncomment and change
# AddHandler cgi-script .cgi
# to
AddHandler cgi-script cgi
# add this line if your Perl scripts use a .pl extension
AddHandler cgi-script pl
#
# To use server-parsed HTML files
#
# uncomment and change
# AddType text/html .shtml
# to
AddType text/html shtml
# uncomment and change
# AddHandler server-parsed .shtml
# to
AddHandler server-parsed shtml
That should be it.
The important thing to remember is that for CGI scripts and SSI to work outside
of the ScriptAlias directory, you'll have to add
ExecCGI and Includes
to your Options for that directory. Also, when
specifying MIME-types, leave out the period in the extension.
If you're not ready for Apache yet (or need help setting up Perl or MySQL under
Windows), read "Your very own
personal web server" for information about how to set up the built-in
Personal Web Server included with Windows 98 .
|