SHARE
Facebook X Pinterest WhatsApp

Apache under Windows Page 6

Written By
thumbnail Rich Bowen
Rich Bowen
Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



ScriptInterpreterSource
On Unix, the first line of a script file, such as a shell script, or a
Perl program, indicates what interpreter is to be used to run the
program. That line will look something like:
     #!/usr/bin/perl

or

     #!/bin/sh

Windows has no concept of looking for the #! (''shebang'') line, but
does everything based on the file extension.

Apache lets you do things either way, as you like. If you are aiming
for platform independence, it is very handy to be able to use the #!
line, so that you can run your CGI programs on your Windows machine,
and also on your Unix machine. But, if you are developing CGI programs
only for Windows, then perhaps this does not matter to you, and you
want it to execute based on the file extension.

The ScriptInterpreterSource directive tells Apache which one of these
you prefer. The default value, script, tells Apache to look for a #!
line to find out what interepreter to use to execute the program.
Setting it to registry will cause Apache to look in the registry for
the association between the file extension and a script interpreter to
run it.

Tip: If you will be using Perl CGI programs, and want to maintain some
level of portability between your Unix machines and your NT machines,
you will want to install Perl in a location on your NT machine that is
the same as on your Unix machines. For example, on my Linux machines,
Perl is located at /usr/bin/perl and so every Perl program that I write
begins with "#!/usr/bin/perl". So, when I install Perl on an NT machine,
instead of installing it in the default location, which is c:perl for
ActivePerl (http://www.activestate.com/), I install it in C:usr so
that the Perl executable is located at /usr/bin/perl. This allows me to
write code on my Windows machine, and then move it, without changes, to
my Linux machine, and have it run there. And vice versa.

Directives that don't work on NT (or, at least, work differently)

Many of the directives that work differently under NT are the ones you'd
expect -- notably the ones dealing with forking child processes. As discussed
above, NT does not use fork, but uses threads, to accomplish what Unix-type
systems use fork for.

There are some other directives that you might want to use, but which you
will need to think about a little differently on NT.

Some of these are just my observations. Perhaps someone can correct me on
these.

UserDir
Users on NT have user directories, but, as the comments in httpd.conf
note,
      # Under Win32, we do not currently try to determine the home directory of
      # a Windows login, so a format such as that below needs to be used.  See
      # the UserDir documentation for details.
      #
      UserDir "C:/httpd/users/"

What this means is that you should just use UserDir in the normal way,
except that you must specify an absolute path.

Under Unix, specifying a relative path causes Apache to append that
path to the home directory of the user specified. That is, if the URL
requested is http://www.rcbowen.com/~rbowen and UserDir is set to
'public_html', Apache will attempt to serve files from
/home/rbowen/public_html.

However, on Win32, there's no nice way to figure out a user's home
directory, so that syntax is unavailable.

XBitHack
thumbnail Rich Bowen

Rich Bowen is a ServerWatch contributor.

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.