This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!
1 Preliminary Note
I have tested this on a Debian Etch system (with Apache2 installed) with a virtual host www.example.com (document root: /var/www/web1/web) which is configured to run Perl scripts in the /var/www/web1/cgi-bin directory. The paths used here might differ from your setup, so adjust them where appropriate.
In the following I will show you three different ways of using SpeedyCGI for your Perl scripts.
2 Installing SpeedyCGI
To install SpeedyCGI together with the SpeedyCGI Apache2 module, we simply run:
Code: Select all
apt-get install libapache2-mod-speedycgi speedy-cgi-perl
Code: Select all
/etc/init.d/apache2 force-reload
3 Using SpeedyCGI
First we create a normal "Hello World!" Perl script to see if Perl is working. At the end of the script, we use some special code that is executed only if SpeedyCGI is used. This helps us to determine when we are in "SpeedyCGI mode" and when in normal "Perl mode". I create the script in my cgi-bin directory, /var/www/web1/cgi-bin:
vi /var/www/web1/cgi-bin/speedy-test.cgi
Code: Select all
#!/usr/bin/perl
### Your Script Here. For example:
print "Content-type: text/html\n\n<h1>Hello World!</h1>\n";
##
## Optionally, use the CGI::SpeedyCGI module for various things
##
# See if we are running under SpeedyCGI or not.
if (eval {require CGI::SpeedyCGI} && CGI::SpeedyCGI->i_am_speedy) {
print "<br>Running under speedy=", CGI::SpeedyCGI->i_am_speedy ? 'yes' : 'no', "\n";
}
(If you are using suExec, you will also have to change the owner and group of the script to match the suExec user and group of this vhost.)chmod 755 /var/www/web1/cgi-bin/speedy-test.cgi
Now we can call that script in a browser (http://www.example.com/cgi-bin/speedy-test.cgi). You should see Hello World!, nothing else:
3.1 Telling Apache To Execute All Perl Scripts Through SpeedyCGI
The first method is to tell Apache that it should execute all Perl scripts through SpeedyCGI if the Perl scripts are in a certain location. We will create an alias /speedy/ that points to our cgi-bin directory, and when we use the /speedy/ address in our browser, the Perl script gets executed by SpeedyCGI, whereas when we use /cgi-bin/, the script is run without SpeedyCGI.
Click here to find out more!
Open the file where your Apache vhost location for www.example.com is located, and add the following lines to it (if you are using ISPConfig, you can simply paste the following lines into the Apache Directives field of the respective vhost):
Code: Select all
Alias /speedy/ /var/www/web1/cgi-bin/
<Location /speedy>
SetHandler speedycgi-script
Options ExecCGI
allow from all
</Location>
/etc/init.d/apache2 restart
Then go to http://www.example.com/speedy/speedy-test.cgi, and you should see that the script is now being executed through SpeedyCGI: