Apache and CGI are not explained here.
1. apache download address: http://www.apache.org, the following uses 2.0.63 as an example to introduce the configuration of running CGI program.
2. Download the Perl interpreter ActivePerl in Windows. Official website: http://www.activestate.com/. the latest version is ActivePerl-5.10.0.1003. Assume that the installation path is c: Perl.
3. Modify the apache configuration file httpd. conf:
The code is as follows: |
Copy code |
<Directory "D:/Apache Group/Apache2/cgi-bin"> AllowOverride None Options None Order allow, deny Allow from all </Directory> # AddHandler cgi-script. cgi Changed: <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 the perl script program hello. pl
The code is as follows: |
Copy code |
#! C: Perlbinperl.exe Print "content-type: text/html", "nn "; 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 under the apache installation directory.
5. Start the apache server, open the browser, and enter http: // localhost/cgi-bin/hello. pl