Step 06 - Perl

It is time to install ActiveState's ActivePerl on your computer. With this package you are able to run any cgi script from your own server.

Installing Perl

  • Load up your setup file for ActivePerl (ActivePerl-5.6.1.633-MSWin32-x86.msi remember).
  • As soon as you accept the license agreement you are greeted with the custom setup screen. Take notice of the location of where Perl will be installed. It seems if you have a D drive on your computer it chooses to install itself on D:\Perl.
  • We don't want that. Incase you haven't noticed, we have tried to install everything under E:\Inet. But with Perl, we are going to make an exception. Why? Because we are going to want to keep some portability between our server on our Windows machine and also our current/future ftp server where there's a 90% chance that Perl will be located on #!/usr/bin/perl.
    So, if you don't want to change the location of Perl in your scripts whenever you transport it, it is wise to install Perl on e:\usr.
    • NOTE:
      .:: What we are actually doing is installing it to the root DRIVE of your server. So, if you have followed through this tutorial installing Apache to say C drive, then install Perl on c:\usr. If you are not getting all of this, worry not... just know that you will do the right thing.
  • So, change the installation directory to e:\usr.
    Press NEXT.
  • I am taking it you are no programmer so just ignore this screen about sending your profile to ASPN.
    Press NEXT.
  • Make sure the first 2 options are checked. The other 2 are meant to be grayed out because you are not supposed to have IIS. You got Apache!
    Press NEXT.
  • Ready to Install?
    Press INSTALL.
  • When all is installed, uncheck the Display Release Notes and press FINISH to complete your installation.
  • Anything visibly different on your computer that would remotely suggest Perl is up and running?
    No.
    Well, let's test then.

Testing Perl

  • Open up notepad. Enter this one line of text:
    print "Hello World";

    Save it as test_perl.pl in E:\Inet\WWW.
  • Open up the command prompt (Type cmd in the run box under the Start menu). And open up test_perl.pl by browsing to the directory you just saved it in. Type the following if you don't know how (pressing the Enter key after each line):
    E:
    cd Inet/WWW
    test_perl.pl
  • Do you see Hello World?
    Perl is in working condition.

Configuring CGI

  • Open up our long time friend httpd.conf from the Apache2/conf folder using Notepad.
  • Find Options Indexes FollowSymLinks (should be on or around Line 267)
    Change it to look like Options Indexes FollowSymLinks ExecCGI Includes
  • Although this is enough to run cgi scripts on our computer, let us enhance our installation of Perl by enabling a few more options:
    The following 'enhancements' are fully optional. Apache & Perl will communicate just fine if you stop here. So it is up to you, just know the difference between enabling the following and not enabling it.
    • CGI in any directory
      Normally you would only be able to run cgi scripts from Apache's dedicated cgi folder (usually Apache2\cgi-bin) if you do not set it up otherwise. The following is the otherwise:

      In httpd.conf, uncomment the following line: #AddHandler cgi-script .cgi so it becomes AddHandler cgi-script .cgi
      Also add .pl behind .cgi so .PL extensions are also treated as cgi files.

      NOTES:
      .:: Uncommet means removing the #.
      .:: If you want security for your cgi-scripts, place them in the Apache2\cgi-bin directory so it is not accessibile to the outside world.

    • Server Side Include [SSI] in any directory
      Uncomment the following lines
      #AddType text/html .shtml
      and
      #AddOutputFilter INCLUDES .shtml


      NOTES:
      .:: You can add .html after .shtml in the AddOutputFilter option to allow SSI without being restricted to a .shtml extension. So it looks like:
      AddOutputFilter INCLUDES .shtml html

Testing CGI

  • RESTART Apache from the monitor on the system tray. Or START if it is off.
  • Open up notepad and paste the following:
    #!/usr/bin/perl
    print "Content-type:text/html\n\n";
    print "Hello World";


    Save it as test_cgi.cgi under your WWW folder.
  • Load your browser and and browse to http://localhost/test_cgi.cgi
    If you see Hello World then you are in business baby!

That was a long one was it not?

 

Return to Step 5