Apache2.2.16 Perl Configuration CGI

Apache2.2.16  Perl Configuration CGI

1. Changes in apache2 configuration file
>cd /etc/apache2
>vi httpd.conf
Add these command there:
#perl here
AddHandler cgi-script .cgi

2. Install the mod_perl packages
>sudo apt-get install libapache2-mod-perl2

3. Continous to configure the apache
>cd /etc/apache2/sites-available
>vi default
Just comment the old configuration blocks, and add our own below:
       
#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#<Directory "/usr/lib/cgi-bin">
#       AllowOverride None
#       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#       Order allow,deny
#       Allow from all
#</Directory>

ScriptAlias /cgi/ /home/luohua/www/perl/
<Directory "/home/luohua/www/perl">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
</Directory>

4. Prepare the perl file in right directory
>cd /home/luohua/www/perl
>vi perl.pl
The content are as follow:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, sillycat.";

Tips here: You must chmod on the file that apache can access it.
>chmod a+x perl.pl

It is done. Try to access this file with your browser.

http://localhost:81/cgi/perl.pl

references:
http://blog.csdn.net/szypanther/archive/2008/11/02/3207692.aspx

你可能感兴趣的:(apache,.net,cgi,perl,Access)