X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=docs%2Fmanual%2Fhowto%2Fcgi.xml;h=3888a98bc4c8af952b95c0b1fff222b24ab02052;hb=aa30f4207c56da1fa7d46bab608590d876e8f3f1;hp=c917bdfc637757883358d8b8f6e49a0a07b8dc90;hpb=69c1a5c854b89a80cf5ca08b7b38d9f0a88c2667;p=apache diff --git a/docs/manual/howto/cgi.xml b/docs/manual/howto/cgi.xml index c917bdfc63..3888a98bc4 100644 --- a/docs/manual/howto/cgi.xml +++ b/docs/manual/howto/cgi.xml @@ -32,6 +32,7 @@ mod_alias mod_cgi + mod_cgid @@ -44,8 +45,9 @@

The CGI (Common Gateway Interface) defines a way for a web server to interact with external content-generating programs, which are often referred to as CGI programs or CGI scripts. It - is the simplest, and most common, way to put dynamic content on - your web site. This document will be an introduction to setting + is a simple way to put dynamic content on + your web site, using whatever programming language you're most + familiar with. This document will be an introduction to setting up CGI on your Apache web server, and getting started writing CGI programs.

@@ -64,9 +66,18 @@ directive has not been commented out. A correctly configured directive may look like this: - + + LoadModule cgid_module modules/mod_cgid.so + + + + On Windows, or using a non-threaded MPM like prefork, A correctly + configured directive may look like this: + + LoadModule cgi_module modules/mod_cgi.so - + +
ScriptAlias @@ -83,9 +94,9 @@

The ScriptAlias directive looks like:

- - ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/ - + +ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/" +

The example shown is from your default httpd.conf configuration file, if you installed Apache in the default @@ -145,13 +156,11 @@ file, to specify that CGI execution was permitted in a particular directory:

- - <Directory /usr/local/apache2/htdocs/somedir>
- - Options +ExecCGI
-
- </Directory> -
+ +<Directory "/usr/local/apache2/htdocs/somedir"> + Options +ExecCGI +</Directory> +

The above directive tells Apache to permit the execution of CGI files. You will also need to tell the server what @@ -160,9 +169,9 @@ files with the cgi or pl extension as CGI programs:

- + AddHandler cgi-script .cgi .pl - +
@@ -180,27 +189,23 @@ .cgi in users' directories, you can use the following configuration.

- - <Directory /home/*/public_html>
- - Options +ExecCGI
- AddHandler cgi-script .cgi
-
- </Directory> -
+ +<Directory "/home/*/public_html"> + Options +ExecCGI + AddHandler cgi-script .cgi +</Directory> +

If you wish designate a cgi-bin subdirectory of a user's directory where everything will be treated as a CGI program, you can use the following.

- - <Directory /home/*/public_html/cgi-bin>
- - Options ExecCGI
- SetHandler cgi-script
-
- </Directory> -
+ +<Directory "/home/*/public_html/cgi-bin"> + Options ExecCGI + SetHandler cgi-script +</Directory> +
@@ -238,11 +243,11 @@ file called first.pl, and put it in your cgi-bin directory.

- - #!/usr/bin/perl
- print "Content-type: text/html\n\n";
- print "Hello, World."; -
+ +#!/usr/bin/perl +print "Content-type: text/html\n\n"; +print "Hello, World."; +

Even if you are not familiar with Perl, you should be able to see what is happening here. The first line tells Apache @@ -346,9 +351,9 @@ interpreter (often perl) indicated in the first line of your CGI program, which will look something like:

- + #!/usr/bin/perl - +

Make sure that this is in fact the path to the interpreter.

@@ -489,15 +494,16 @@ add your own environment variables to the basic ones provided by default.

- - #!/usr/bin/perl
- print "Content-type: text/html\n\n";
- foreach $key (keys %ENV) {
- - print "$key --> $ENV{$key}<br>";
-
- } -
+ +#!/usr/bin/perl +use strict; +use warnings; + +print "Content-type: text/html\n\n"; +foreach my $key (keys %ENV) { + print "$key --> $ENV{$key}<br>"; +} +
@@ -582,4 +588,3 @@ have found a problem in the Apache source code.

-