adding Perl to WAMP server

As a bit of a distraction from studying (I know, I know, just do the study) I decided to play with Perl a little; hence, I needed to install it to my localhost server. I’m running WAMP, and doing everything in PHP at present, which is great but Perl required a bit of reconfiguration. Just thought I’d share the steps, as they are pretty simple if you know them but otherwise can be a bit daunting.

First, download WampServer from and install WampServer. The default installation directory is ‘C:\wamp” and I find this to be the best too.

WampServer 2.0i [07/11/09] includes :
– Apache 2.2.11
– MySQL 5.1.36
– PHP 5.3.0

The links above will download it directly for you from the site.

Now you have to download ActivePerl (currently 5.10.0) from and install it. The default installation directory is “C:\Perl”, but I throw this in a new folder called “perl” inside “C:\wamp\bin”. So just create this folder and point to it during the installation. Now we need to configure the Apache web server to execute Perl and CGI script.

We need to edit the Apache configuration file. You can either go to “C:\wamp\bin\apache\Apache2.2.11\conf” directory and open “httpd.conf” file; or run WampServer and left click the taskbar icon,  hover over “Apache” and then click “httpd.conf” to open it in your text editor. Edit the httpd.conf file as below.

Note: It is best to save a backup copy of your httpd.conf file before editing; that way, if you do “break” it, you have an original to go back to without major damage issues.

1. Inside httpd.conf, look for the line that says “<Directory “c:/wamp/www/”>“, just a few lines below this you’ll find the line that says “Options Indexes FollowSymLinks”. Add “Includes ExecCGI” in the line just next to FollowSymLinks, thus it look like this”

Options Indexes FollowSymLinks Includes ExecCGI

This will enable CGI script inside your www folder.

2. Now look for the line “AddHandler cgi-script .cgi“, this line is commented out. You need to enable this by un-comment this line, to do that remove the # character at the beginning of this line. This will add handler for files with .cgi extension. If you want to use .pl file extension in your server add “AddHandler cgi-script .pl” just below the above line. Now you will be able to execute CGI and Perl script with .cgi and .pl, extension.

AddHandler cgi-script .cgi
AddHandler cgi-script .pl

3. To add directory index file, look for the line “DirectoryIndex index.php index.php3 index.html index.htm“. Addindex.cgi and in this line.

DirectoryIndex index.php index.php3 index.html index.htm index.cgi

Your server is now configured and ready to run perl and cgi script. Next thing you might need to do is to configure perl to use mysql database. You need to download and install mysql driver to enable database connection through your perl script. You have to grab the driver from the ActivePerl package repository. However, mysql driver module is not available in the default ActivePerl Package Repository. So, you need to add additional repository and install from that repository. Follow the steps below:

1. Open command prompt [type cmd in run], then type “ppm repo add uwinnipeg” and press enter.

2. After the “uwinnipeg” repository is added successfully, you can install DBD-mysql by typing this command “ppm install DBD-mysql” and hit enter.

CMD window adding UWinnipeg repository

Note: The ActivePerl default package repository contains DBD-mysqlPP module. If you install that one, you will get an error in your SQL SELECT query and especially when you use the WHERE clause. Your localhost will hang if you run this kind of query with the WHERE clause, so to get it work you need to install the package that I mentioned above only.

So, there you go. Hopefully that’s simplified your day a little. I’ll be throwing up some Perl tutorials in a week or two, once exams are over and I’ve had a decent play around.