Configuring Apache Web Server to Run Perl Programs on Windows
May 25, 2021
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
As shown in the screenshot below:
- How to install Apache web server with PHP, MySQL and phpMyAdmin on Windows (72.8%)
- What is open_basedir for and how to use open_basedir (69.9%)
- Apache window appears and immediately disappears (SOLVED) (63.8%)
- How to get data from a web page using GET and POST methods in a Python script on Windows (63.8%)
- How to fix “Configuration File (php.ini) Path” no value (SOLVED) (60.8%)
- Connection type “Bridged Adapter” stopped working on VirtualBox guest machine (SOLVED) (RANDOM - 50%)