diff options
Diffstat (limited to 'docs/manual/howto/cgi.html.en')
-rw-r--r-- | docs/manual/howto/cgi.html.en | 128 |
1 files changed, 78 insertions, 50 deletions
diff --git a/docs/manual/howto/cgi.html.en b/docs/manual/howto/cgi.html.en index 408f5f97..2c343515 100644 --- a/docs/manual/howto/cgi.html.en +++ b/docs/manual/howto/cgi.html.en @@ -8,10 +8,13 @@ <title>Apache Tutorial: Dynamic Content with CGI - Apache HTTP Server</title> <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> -<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /> +<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -31,7 +34,7 @@ <li><img alt="" src="../images/down.gif" /> <a href="#behindscenes">What's going on behind the scenes?</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#libraries">CGI modules/libraries</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#moreinfo">For more information</a></li> -</ul></div> +</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="intro" id="intro">Introduction</a></h2> @@ -62,9 +65,10 @@ directive has not been commented out. A correctly configured directive may look like this: - <div class="example"><p><code> + <pre class="prettyprint lang-config"> LoadModule cgi_module modules/mod_cgi.so - </code></p></div></div> + </pre> +</div> <h3><a name="scriptalias" id="scriptalias">ScriptAlias</a></h3> @@ -81,9 +85,10 @@ <p>The <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code> directive looks like:</p> - <div class="example"><p><code> + <pre class="prettyprint lang-config"> ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/ - </code></p></div> + </pre> + <p>The example shown is from your default <code>httpd.conf</code> configuration file, if you installed Apache in the default @@ -136,13 +141,12 @@ file, to specify that CGI execution was permitted in a particular directory:</p> - <div class="example"><p><code> - <Directory /usr/local/apache2/htdocs/somedir><br /> - <span class="indent"> - Options +ExecCGI<br /> - </span> - </Directory> - </code></p></div> + <pre class="prettyprint lang-config"> +<Directory /usr/local/apache2/htdocs/somedir> + Options +ExecCGI +</Directory> + </pre> + <p>The above directive tells Apache to permit the execution of CGI files. You will also need to tell the server what @@ -150,9 +154,10 @@ files with the <code>cgi</code> or <code>pl</code> extension as CGI programs:</p> - <div class="example"><p><code> + <pre class="prettyprint lang-config"> AddHandler cgi-script .cgi .pl - </code></p></div> + </pre> + <h3><a name="htaccess" id="htaccess">.htaccess files</a></h3> @@ -170,27 +175,25 @@ <code>.cgi</code> in users' directories, you can use the following configuration.</p> - <div class="example"><p><code> - <Directory /home/*/public_html><br /> - <span class="indent"> - Options +ExecCGI<br /> - AddHandler cgi-script .cgi<br /> - </span> - </Directory> - </code></p></div> + <pre class="prettyprint lang-config"> +<Directory /home/*/public_html> + Options +ExecCGI + AddHandler cgi-script .cgi +</Directory> + </pre> + <p>If you wish designate a <code>cgi-bin</code> subdirectory of a user's directory where everything will be treated as a CGI program, you can use the following.</p> - <div class="example"><p><code> - <Directory /home/*/public_html/cgi-bin><br /> - <span class="indent"> - Options ExecCGI<br /> - SetHandler cgi-script<br /> - </span> - </Directory> - </code></p></div> + <pre class="prettyprint lang-config"> +<Directory /home/*/public_html/cgi-bin> + Options ExecCGI + SetHandler cgi-script +</Directory> + </pre> + @@ -228,11 +231,12 @@ file called <code>first.pl</code>, and put it in your <code>cgi-bin</code> directory.</p> - <div class="example"><p><code> - #!/usr/bin/perl<br /> - print "Content-type: text/html\n\n";<br /> - print "Hello, World."; - </code></p></div> + <pre class="prettyprint lang-perl"> +#!/usr/bin/perl +print "Content-type: text/html\n\n"; +print "Hello, World."; + </pre> + <p>Even if you are not familiar with Perl, you should be able to see what is happening here. The first line tells Apache @@ -336,9 +340,10 @@ interpreter (often <code>perl</code>) indicated in the first line of your CGI program, which will look something like:</p> - <div class="example"><p><code> + <pre class="prettyprint lang-perl"> #!/usr/bin/perl - </code></p></div> + </pre> + <p>Make sure that this is in fact the path to the interpreter.</p> @@ -476,15 +481,17 @@ <a href="../env.html">add your own environment variables</a> to the basic ones provided by default.</p> - <div class="example"><p><code> - #!/usr/bin/perl<br /> - print "Content-type: text/html\n\n";<br /> - foreach $key (keys %ENV) {<br /> - <span class="indent"> - print "$key --> $ENV{$key}<br>";<br /> - </span> - } - </code></p></div> + <pre class="prettyprint lang-perl"> +#!/usr/bin/perl +use strict; +use warnings; + +print "Content-type: text/html\n\n"; +foreach my $key (keys %ENV) { + print "$key --> $ENV{$key}<br>"; +} + </pre> + <h3><a name="stdin" id="stdin">STDIN and STDOUT</a></h3> @@ -572,7 +579,28 @@ <a href="../fr/howto/cgi.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | <a href="../ja/howto/cgi.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | <a href="../ko/howto/cgi.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> -</div><div id="footer"> +</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/howto/cgi.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> </body></html>
\ No newline at end of file |