Loading...
X

Configuring Apache Web Server to Run Perl Programs on Windows

Perl scripts can be run in the Apache environment in the same way as PHP scripts. To do this, you need to make a small setting.

I installed the web server according to this instruction, if you installed according to a different instruction, then edit the paths to suit your values.

1. Installing Perl on Windows

Download Perl for Windows from https://www.activestate.com/products/activeperl/downloads/

Run the downloaded .exe file – installation can be done with default options.

2. Configuring Apache to run Perl CGI

Now open the httpd.conf file for editing, I have it located along the path C:\Server\bin\Apache24\conf\httpd.conf.

Find the line there

Options Indexes FollowSymLinks

and add ExecCGI to it. You should get the following line (ATTENTION: you may have a different set of options):

Options Indexes FollowSymLinks ExecCGI

Now find the line:

#AddHandler cgi-script .cgi

Uncomment it, that is, remove the # at the beginning of the line and add .pl to the end of the line. The new line will look something like this:

AddHandler cgi-script .cgi .pl

3. Restart Apache

c:\Server\bin\Apache24\bin\httpd.exe -k restart

4. Run the Perl CGI test page

In the folder for your sites (mine is C:\Server\data\htdocs\) create a file test.pl and copy into it:

#!C:\Perl64\bin\perl.exe
print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<phtml>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";

Pay attention to the line #!C:\Perl64\bin\perl.exe – if you have a different path to the perl.exe file, then edit the line accordingly.

Open this page in a web browser: http://localhost/test.pl

The inscription should appear

Test Page

As shown in the screenshot below:


Leave Your Observation

Your email address will not be published. Required fields are marked *