
Example 40.5
VirtualHost CGI Configuration
ScriptAlias /cgi-bin/ "/srv/www/example.com_cgi-bin/"
❶
<Directory "/srv/www/example.com_cgi-bin/">
OExecCGI
❷
AddHandler cgi-script .cgi .pl
❸
Order allow,deny
❹
Allow from all
</Directory>
❶
Tells Apache to handle all files within this directory as CGI scripts.
❷
Enables CGI script execution
❸
Tells the server to treat files with the extensions .pl and .cgi as CGI scripts. Adjust
according to your needs.
❹
The
Order
and
Allow
directives control the default access state and the order
in which Allow and Deny directives are evaluated. In this case “deny” statements
are evaluated before “allow” statements and access from everywhere is enabled.
40.5.2 Running an Example Script
CGI programming differs from "regular" programming in that the CGI programs and
scripts must be preceded by a MIME-Type header such as
Content-type:
text/html
. This header is sent to the client, so it understands what kind of content
it receives. Secondly, the script's output must be something the client, usually a Web
browser, understands—HTML in most cases or plain text or images, for example.
A simple test script available under
/usr/share/doc/packages/apache2/
test-cgi
is part of the Apache package. It outputs the content of some environment
variables as plain text. Copy this script to either
/srv/www/cgi-bin/
or the script
directory of your virtual host (/srv/www/example.com_cgi-bin/) and name it
test
.cgi
.
Files accessible by the Web server should be owned by to the user
root
(see
Sec-
tion 40.7, “Avoiding Security Problems”
(page 772) for additional information). Because
the Web server runs with a different user, the CGI scripts must be world-executable
and world-readable. Change into the CGI directory and use the command
chmod 755
test.cgi
to apply the proper permissions.
The Apache HTTP Server
765
Содержание LINUX ENTERPRISE SERVER 10 - INSTALLATION AND ADMINISTRATION 11-05-2007
Страница 1: ...SUSE Linux Enterprise Server www novell com 10 May 11 2007 Installation and Administration...
Страница 14: ......
Страница 19: ...Part I Deployment...
Страница 20: ......
Страница 60: ......
Страница 128: ......
Страница 243: ...Part II Administration...
Страница 244: ......
Страница 274: ......
Страница 312: ......
Страница 348: ......
Страница 380: ......
Страница 381: ...Part III System...
Страница 382: ......
Страница 438: ......
Страница 452: ......
Страница 478: ......
Страница 486: ......
Страница 498: ......
Страница 512: ......
Страница 558: ......
Страница 559: ...Part IV Services...
Страница 560: ......
Страница 652: ......
Страница 670: ......
Страница 742: ......
Страница 754: ......
Страница 796: ......
Страница 817: ...Part V Security...
Страница 818: ......
Страница 858: ......
Страница 886: ......
Страница 910: ......
Страница 911: ...Part VI Troubleshooting...
Страница 912: ......
Страница 924: ......