Reputation: 955
I am developing a a PHP web site but I am using Perl CGI for file uploads with progress.
I have installed ActivePerl under WAMP.
As I am developing the site to run on a Unix server I want to mirror that environment locally, so I want to execute CGI files outside of the WAMP cgi-bin.
How can I do that?
Upvotes: 2
Views: 4889
Reputation: 2348
I work on Perl and CGI recently for Movable Type on Localhost so I was doing few steps on setting up Perl and CGI with Wamp Server. I hope this might be useful.
Step1: First you need to download Wamp Server from www.wampserver.com and install Wamp Server on your machine. The default installation directory is ‘C:\wamp” and here I am using the default options for installation. To complete the installation you have to set the host name for your mail server and your email address, here you can leave the default option again. That will do no harm.
The current Wamp Server will install Apache 2.2.11, PHP 5.2.9-2 + PECL, MySQL 5.1.33, SQLitemanager and PhpMyadmin.
Step2: Now you have to download ActivePerl (currently 5.10.0) from http://www.activestate.com/activeperl/downloads and install it. The default installation directory is “C:\Perl“, but for simplicity and ease of use I use different directory. I create a new folder name “perl” inside “C:\wamp\bin“. So I install Active Perl in “C:\wamp\bin\perl” directory. The next thing you need to do is configure the Apache web server to execute Perl and CGI script.
Step3: This is the most important part here. You need to edit the Apache configuration file. Now go to “C:\wamp\bin\apache\Apache2.2.11\conf” directory and open “httpd.conf” file. Edit the httpd.conf file as below.
1. Inside httpd.conf, look for the line that says ““, just a few lines below this you’ll find the line that says “Options Indexes FollowSymLinks“. Add “Includes ExecCGI” in the SAME line with FollowSymLinks, thus it will change from:
And now becomes:
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.
Lines to add
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“. Add index.cgi and index.pl in this line.
Lines to add
1. DirectoryIndex index.php index.php3 index.html index.htm index.cgi index.pl
DirectoryIndex index.php index.php3 index.html index.htm index.cgi index.pl
Alternative: If you do not want to waste your time doing the above 3 steps, you can download the edited configuration file httpd.conf here. Replace the one inside your apache directory with this one.
Step4: 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:
Go to DOS Command Prompt and type “PPM”. Now type “Install DBI” > ENTER. Once that install is done, type “Install DBD-mysql” > ENTER. You should be done by now.
we will have to modify some setting of all our cgi files, well we have to modify all cgi files that you get as commonly they will point to perl like “#!/usr/bin/perl” but we do not have that convention in windows. The change is just on the first line of your CGI files, so it shoould be easy. Change any reference to perl in your cgi files to your current location. Keep in mind if you have not enabled environment variable path during perl installation, you will have to give a full path like “c:\perl\bin\perl.exe” but if you have given the path in the environment variable, you can simply do “perl.exe” so most of our cgi files with have the first line as “#!perl.exe -w”, without the quotes though.
Upvotes: 6
Reputation: 773
Depending on your webserver, on W(in) it is often IIS.
You can have any virtual folder point to your perl-script folder. Then you need to set c:\Perl\bin\perl.exe "%s" %s to be a handler for *.pl for this folder. See e.g. http://community.activestate.com/forum-topic/configuring-perl-iis-7-0 for details. (under item 7, I think pressing Yes is the right thing to do). To make a virtual folder, open Internet Information Services (IIS) Manager, and browse down to Default Web Site, then Right-Click and add Virtual Directory. You may also have to install some modules for iis (under windows Control Panel -> Applications & Features -> Turn features on -> iis-> www -> Appl-> CGI etc)
If Apache add *.cgi, or *.pl as a handler, as described in e.g. http://www.thesitewizard.com/archive/addcgitoapache.shtml
Best wishes!
Upvotes: 0