My Configurations
My system is configured as follows:
Web root = c:/www
Apache version = 2.4
Apache installation directory = c:/Apache2.4/
Download ActivePerl
Download windows MSI version from http://www.activestate.com/store/activeperl/download
Install ActivePerl
Double click on the downloaded file to install it. By default it installs at c:/Perl.
Test Installation
To test whether the installation was successfull, we need to create and run a hello world file.
c/Perl/bin/perl
print "Hello, World...\n";
Save the file as c:/www/hello.pl
Type cmd in window search at the bottom left and click on Command Prompt. Then type the following command in the window.
perl hello.pl
If you see Hello, World…, Perl installed correctly, otherwise reinstall ActiveState Perl.
Activate CGI
Open httpd.conf change
Options Indexes FollowSymLinks
to
Options Indexes FollowSymLinks ExecCGI
ExecCGI tells Apache to execute CGI. Next, change
# AddHandler cgi-script .cgi
to
AddHandler cgi-script .cgi .pl
Now .cgi and .pl files could be executed as CGI.
Test CGI
Type the following code.
#!/Perl/bin/perl
print "Content-type:text/html\n\n";
print "hello world";
Save it as c:/Apache2.4/cgi-bin/hello.cgi. View http://localhost/cgi-bin/hello.cgi in your browser. If you see hello world, CGI is working correctly.
Running CGI from another address
Very often you would not want to run CGI from an Apache directory. To change the cgi-bin, create the folder
c:/www/cgi-bin/
Then edit your httpd.conf file. The ScriptAlias line should look as follows:
ScriptAlias /cgi-bin/ C:/www/cgi-bin/
and change
<Directory "C:/Apache2.4/cgi-bin">
to
<Directory "C:/www/cgi-bin">
Errors
Perl errors are logged in the Apache error log. To view it, go to Start > Apache HTTP Server 2.4 > Review Server Log Files > Review Error Log or C:/Apache2_4/logs/error.log