Configuration method running cgi mode under apache

  • 2020-05-07 20:50:05
  • OfStack

1, apache download address: http: / / www apache. org, 2.0.63, for example to introduce below run CGI application configuration.

2, download Windows Perl interpreter ActivePerl, official website: http: / / www activestate. com /, the latest version ActivePerl - 5.10.0.1003, assuming that the installation path for c: \ Perl.

3. Modify the configuration file httpd of apache.conf:


<Directory "D:/Apache Group/Apache2/cgi-bin"> 
AllowOverride None 
Options None 
Order allow,deny 
Allow from all 
</Directory> 
#AddHandler cgi-script .cgi 

To:

<Directory "D:/Apache Group/Apache2/cgi-bin"> 
AllowOverride None 
Options ExecCGI 
Order allow,deny 
Allow from all 
</Directory> 
AddHandler cgi-script .cgi .pl 

4, write perl script hello.pl


#!C:\Perl\bin\perl.exe 
print "content-type: text/html","\n\n"; 
print "<HTML>","\n"; 
print "<HEAD>","\n"; 
print "<TITLE>Perl</TITLE>","\n"; 
print "</HEAD>","\n"; 
print "<BODY>","\n"; 
print "<H1>Hello World</H1>","\n"; 
print "</BODY>","\n"; 
print "</HTML>","\n"; 

Copy the program to the cgi-bin folder in the apache installation directory

5. Start the apache server, open the browser, and type http://localhost/ cgi-bin/hello.pl
Results: Hello World


Related articles: