Running Perl Scripts

WampDeveloper is primarily a PHP web-server, but it does come with Perl (StrawberryPerl distribution), and is able to run perl scripts out-of-the-box.

Simple Perl Scripts

For simple perl scripts (not entire perl based applications), just place the perl scripts into the website’s \cgi-bin folder (up one level from \webroot) -

C:\WampDeveloper\Websites\www.example.com\cgi-bin\

Then you can access those scripts via URL -

http://www.example.com/cgi-bin/script-file-name.pl

Entire Perl Applications

For more complicated perl applications -

Because of the size and complexity of some perl applications, it’s not going to be good enough to place those perl applications into the website’s default \cgi-bin folder… We’ll rather have to place the application into the website’s \webroot folder, and enable CGI execution in the application’s folder….

Edit the website’s VirtualHost file (select website in Websites Tab, click VirtualHost buttons), inside the <VirtualHost> block add in…

<Directory "C:/WampDeveloper/Websites/www.example.com/webroot/perl-application-folder-to-enable-cgi-for">
DefaultType text/html

Options -Indexes +ExecCGI
AllowOverride None

Order allow,deny
Allow from all

SetHandler cgi-script
</Directory>

Save file. Restart Apache.

If Apache won’t start, from the command-line (button in System Tab), run -

httpd -t
httpd -k start

This will tell you which lines in the VirtualHost file have errors in them.

Extra Perl Modules

Some perl applications might also require extra perl modules to be installed. To do so, open the command-line (button in System Tab) -

Then run something similar to this (substitute in package-names) -

perl -MCPAN -e shell;
install package::name1
install package::name2
...
exit

This might, or might not, work out well – depending on the extra modules and what they require.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>