Installing Perl on a local Windows-based, Apache, server

Note: This guide should work equally well for ActivePerl 5.8.8.817 and above. For a guide on upgrading this 5.8.7.815 install, see Upgrading (our local install of) ActivePerl.

Now that we've installed Apache, configured our log files, and setup a log file analysis tool, it's time to install Perl. Perl will allow us to expand our horizons, and specifically will help us install a better log analyzer.

To install Perl, we're going to download ActivePerl from ActiveState. Navigate to http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl, and download the MSI file for Windows. When writing this, the current version is 5.8.7.815, and the download size is very large 12.7 MB.

Once we've downloaded this file, we'll open it. Read and accept the license, and on the next screen, leave the installed settings alone, but change the Location from C:\Perl\ to C:\usr. We'll be doing that in order to keep with Linux (just like we installed our content to C:\home).

On the next screen, keep the first two boxes checked, and leave everything else unchecked. Finally, hit the Install button to begin the installation.

Once the rather long installation has finished, we'll need to modify the Apache httpd.conf file so it can recognize Perl.

To do this, open up the httpd.conf file as before, using the Start menu or the shortcut in your main Web folder. Now, search for "ExecCGI". Scroll down to the first uncommented line, and add the following information, displayed as bold text.

Options Indexes FollowSymLinks MultiViews ExecCGI Includes

Now do a search for "AddHandler". Scroll down a couple of lines until you reach the commented lines below.

# To use CGI scripts:
#
#AddHandler cgi-script .cgi

#
# To use server-parsed HTML files
#
#AddType text/html .shtml
#AddHandler server-parsed .shtml

Remove the comments from the three lines so that the above becomes the following. Note that lines changed are bold. We'll also add the .pl extension to the end of the first uncommented line, to allow another file type to be run.

To use CGI scripts:

#
AddHandler cgi-script .cgi .pl

#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml

The last two lines will allow us to add simple server-side pages to our site. These files are created on the server, and then displayed to the user. Using server-parsed HTML files, we can create a standard header and footer that is displayed on every page (so long as we tell the page to include it).

Finally, do a search for "ScriptAlias /cgi-bin/" and comment this line. So, when you're done, it should read as follows.

#ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"

This change will allow us to place, and run, CGI scripts in any folder, not just the above folder.

Once these changes have been made, save the httpd.conf file, and restart Apache. Now that Apache has been restarted, we'll test our installation of Perl. To do this, open Notepad and copy or type the following text into it.

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "Hello world!";

Save this file into C:\home\, and call it TestCGI.cgi. Now, go to http://localhost/TestCGI.cgi. The page should load with the text of "Hello world!".

View all of the steps to creating a local Web server, for development.