|
|
Question : Run CGI in Apache for windows (beginner question)
|
|
I am new to Apache. I have just installed Apache2 "apache_2.0.39-win32-x86-no_ssl.exe" on my windows2000 Professional and my site works fine.
I want to run CGI script written in Perl or C+ and SSI. What do I need? Step by step please.
PS: I also need LWP. Please rememeber that it is an Windows Environment. Some useful URLs are welcomed.
Thanks in advance
|
Answer : Run CGI in Apache for windows (beginner question)
|
|
Leekf, By default Apache (for whatever platform) is ready for CGI. Just make sure all you scripts/program are in fact executable, and would sends out the proper HTTP header, and you are ready to go. There are two ways to have the program to run as CGI program; 1. Place in in c:\program files\apache group\apache2\cgi-bin, OR 2. configure your server to map certain file extension as CGI program, and add appropriate directive in httpd.conf 3. Configre ScriptAlias The Option #1 is straight forward.
For option #2, you would need to ; (my example are based on Apache 1.3.x, but it should not be much different).
-In httpd.conf, look for this section; Just add the file extension that you want to be executed as CGI; ----------- # # To use CGI scripts: # AddHandler cgi-script .cgi .pl .exe -----------
And for each directory that you want to have the CGI program to be executed, just add "ExecCGI" in the Option directive.
Alias /mrtg/ "C:/Websites/"
Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride None Order allow,deny Allow from all
For option #3; -- Straight from httpd.conf.
# 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. # ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/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. # AllowOverride None Options None Order allow,deny Allow from all
To enable, SSI, look for the following, and uncomment the AddType, and AddHandler directive.
# To use server-parsed HTML files # #AddType text/html .shtml #AddHandler server-parsed .shtml
Once you had you Apache configured, and ready to run CGI as you preferred, next, you woould need to pick the programming language for the CGI. C, C++, or any language would be fine. If you prefer Perl, then grab yourself the Perl for Win32 from ActiveState (www.activestate.com) I think the latest version is 5.6.1). Download the MSI file, and choose Full Install.
Once installation is completed, you can use Perl Package Manager (PPM) to Install any additional perl Modules that you require. LWP would be part of Standard ActivePerl distribution (try doing "perldoc lwp" from command prompt).
To add additional perl modules, run "ppm" or "ppm3" from command prompt. do a "search " and "install pkg#" to search and install certain pkg. doing a "help" would display the usage.
I hope the information would get you started.
good luck.
|
|
|
|
|