This is a step-by-step guide on how to install and configure Apache on Windows Vista to run Perl scripts.
1. Uninstall any previous version of Apache Web Server. Stop other servers such as IIS, and any other programs that use port 80, such as Skype. Manually remove all folders left behind after uninstallation.
2. Download the most recent Win32 binaries from http://httpd.apache.org/download.cgi and put it on your desktop
3. Stop User Access Control and reboot.
4. Go to Start>All Programs>Accessories, right click “Command Prompt” and choose “Run as Administrator”
5. At the prompt, type “cd desktop” and enter, then “msiexec /I apache” and tab, which should complete the command and specify the .msi file you’ve downloaded. Press enter to start installation.
6. Install Apache for all users, and choose the default port 80 for all users.
8. Browse to http://localhost. It will say “It works!”.
9. Go to http://www.activestate.com/activeperl/ and download ActivePerl for windows.
10. Run the installation program to install.
11. Run Perl Package Manager and install all packages your scripts depend on.
12. Make a folder which will serve as the root folder for Apache. For this example, I’ll make a root folder at D:/wwwroot.
13. Create 2 subdirectories in your root folder, one for images (D:/wwwroot/images) and one for scripts (D:/wwwroot/cgi-bin).
14. Place all your html files in your root folder, your images in your images folder, and your scripts in your cgi-bin folder. By default, all http requests are referenced from your root folder, so you may have to re-specify all the image src tags in your html files to point at “/images/xxx.jpg”, and all your scripts references will have to be similarly re-worked.
15. All html files must start with the line “Content-type:text/html” to tell the server what type of file its supposed to serve. All rss files should start with Content-type:text/xml. All perl scripts must start with the line “#!C:/Perl/bin/perl” or wherever your perl.exe is located, to tell Apache where to find the interpreter to interpret your script.
16. Now its time to configure Apache. First open the httpd.conf file, which is located in the conf subdirectory of your Apache main directory.
17. Specify a new document root. Comment out the old line which reads “DocumentRoot “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs”, and put in your own folder, for example “DocumentRoot “D:/wwwroot “
18. Next we specify the permissions for the document root by looking for the line “, and changing that line to read . Among the code contained within the tags, there should be a line that reads “Options Indexes FollowSymLinks”; append the term “ExecCGI” to the line, so that it now reads “Options Indexes FollowSymLinks ExecCGI”. This will allow Apache to execute scripts from your root folder.
19. Then, we specify the directory from which to serve scripts. Look for the line “ScriptAlias /cgi-bin/ “C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/”, and change that to “ScriptAlias /cgi-bin/ “D:/wwwroot/cgi-bin/”.
20. Then we set the permissions for the script directory. Look for the line , change that to . Leave the code within the Directory tags alone.
21. Then, we switch on perl script handling. Look for the line “#AddHandler cgi-script .cgi”, change it so that it reads “AddHandler cgi-script .cgi .pl”. This will allow Apache to recognize .pl files as script files.
22. Lastly, we save the http.conf file. To load the new configuration file, click on the Apache icon on the Task bar and mouse over the Apache 2.2 text, then choose “Restart” to restart the Apache server.
23. Load a simple test.pl script from your cgi-bin folder to see whether everything is okay. You can access your cgi-bin folder at the address http://localhost/cgi-bin/test.pl from your browser.
24. If you hit any problems, open the error.log file in the log folder under Apache’s program folder. The error log is extremely detailed and helpful in troubleshooting any difficulties.