This is a step-by-step of getting Apache on a Win NT4.0+
machine and then convincing it to do CGI. This is not
an exhaustive treatment of the subject. But, a newbie
should be able to follow this pattern and end up with Apache
on a M$ box capable of doing CGI stuff. I am severely
neglecting security issues here. There are so many posts
about getting CGI to work on a Win box, that this is intended
to answer that specifically. The topic of web server setup
is much larger and can't be done as a FAQ. There are lots of
books on the subject. If you are going to be doing any
significant amount of CGI, buy one. See http://www.Oreilly.com.
Onward and maybe upward.....
[paraphased from www.apache.org]
"If you will install apache on Windows 95, download and install
the Windows Socket 2 Update from Microsoft, available at
http://www.microsoft.com/windows/downloads/bin/W95ws2setup.exe,
before you proceed to download and install Apache on Windows 95."
1 - Read the above about win95. Do it if you need.
2 - Download the apache server from
http://httpd.apache.org/dist/httpd/binaries/win32/ and install it.
READ the panels in the installer as they go by. Some of it is
important. Like, don't use Win95, 98 or ME as public web servers.
They are not securable and you may get spanked. Fill the fields
and let it install.
The default behavior will start the apache server for all users
when ever the box is booted. To get Apache running so you can
learn CGI, it is fine. If you don't want the server to start
every time you boot, change it. If you are installing it for a
public server, change it. You will need to read the part of the
Apache docs about starting and stopping the server manually.
If you want to know why not on a public
server, go to www.apache.org and start reading.
3 - confirm that apache is installed and running by opening
a browser and putting 'localhost' in the location (url). You should
get the statement,
"If you can see this, it means that the installation of the Apache web server software on this system was successful."
If you don't get that, try going to '127.0.0.1'. If that does not
work, then go to www.apache.org and start reading. Normally, it
should work if you put reasonable stuff in the installer fields. If it
does not, there are to many possible reasons to try to address here.
4 - Next, you must configure Apache to run CGI programs.
The web server won't execute programs anywhere on the file system.
The programs must be where Apache expects to find executables.
The default install creates a 'cgi-bin' directory at
'C:/Program Files/Apache Group/Apache/cgi-bin/'
To run files in that directory, there are several ways to configure
Apache. One way is, in your 'httpd.conf' file, make sure the 'ScriptAlias'
directive is pointed at the 'cgi-bin' directory and that it is not commented out.
It might (should) look like,
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
That file should be in "C:/Program Files/Apache Group/Apache/conf/".
5 - put a valid piece of cgi code in your new cgi-bin directory. Save the
following trivial piece of code into a plain text file named simple.cgi in
your cgi-bin directory.
#!perl
print "Content-type: text/html\n\n";
print "Not the ubiquitous 'Hello World!'\n";
You may have to change the first line, '#!perl' to point at the perl.exe on the box.
It maybe something like '#!/perl/bin/perl'. (a likely guess)
Then, in a browser, go to http://localhost/cgi-bin/simple.cgi
You should see "Not the ubiquitous 'Hello World!'" in your browser.
If that worked, congratulations!, you successfully installed Apache,
configured it for CGI, wrote a little CGI, and ran it. You should now
be able to go to FAQ452-653 for a little more.
I just did this series of steps on my machine and it worked. If you
have trouble, post to Tek-Tips or read the Apache documentation.
If you got the server installed and running, there is a link on the
front page to the apache documentation and in there is a link to
'Dynamic Content with CGI' which is a more useful document than
this FAQ is.
PLEASE be aware that I have really really neglected security here.
You can start learning here, http://www.w3.org/Security/faq/wwwsf4.html
I hope this helps.
I am no guru, but, there are so many questions about this stuff
that I thought this FAQ might be helpful. If anyone sees any
gross omissions or errors, please let me know so I can fix them
as quickly as possible. There should be a link on this page for
just that purpose.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.