让Apache支持cgi、SSI、shtml的配置方法
1.首先明确,只能够指定某个确定的目录,支持cgi,即运行该目录执行cgi程序;否则不太安全。 复制代码 代码如下: # # "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists,if you have that configured. # <Directory "E:/Website_Field/cgi"> AllowOverride all Options all Order allow,deny Allow from all </Directory> 设置Directory为可以执行cgi的目录 2. 复制代码 代码如下: # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases,except that # documents in the realname directory are treated as applications and # run by the server when requested rather than as documents sent to the client. # The same rules about trailing "/" apply to ScriptAlias directives as to # Alias. # ScriptAlias /cgi-bin/ "E:/Website_Field/cgi" 将之后的目录改成和上面的相同。 3. 复制代码 代码如下: # # AddHandler allows you to map certain file extensions to "handlers", # actions unrelated to filetype. These can be either built into the server # or added with the Action command (see below) # # If you want to use server side includes,or CGI outside # ScriptAliased directories,uncomment the following lines. # # To use CGI scripts: # AddHandler cgi-script .cgi .pl 设置后缀如.cgi,.pl等等,任意可以想到的,但是避免使用已有的如.html,.asp,.php等 注意:设置支持cgi的目录之后,该目录下的内容及子目录的内容都可以执行。 配置Apache支持SSI,即服务器端解析的server-parsed html(shtml) 1. 配置Apache: 复制代码 代码如下: # # To use server-parsed HTML files # AddType text/html .shtml AddHandler server-parsed .shtml 去掉后两行之前的#号; 复制代码 代码如下: # # "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists,if you have that configured. # <Directory "E:/Website_Field/shtml"> AllowOverride all Options all Order allow,deny Allow from all </Directory> 从Directory开始进行修改: 首先指定到自己的目录,这里是"E:/Website_Field/shtml"; 然后设置各个选项如上: 复制代码 代码如下: AllowOverride all Options all Order allow,deny Allow from all 完后重启Apache应该就可以了。 2. 关于Apache支持的SSI指令,可以参考如下介绍: 3. 一个使用SSI的shtml页面实例: 复制代码 代码如下: <html> <head> <title>shtml</title> </head> <body> <!--#config timefmt="%D" --> This file last modified <!--#echo var="LAST_MODIFIED" --><br /> <!--#config timefmt="%A %B %d,%Y" --> Today is <!--#echo var="DATE_LOCAL" --><br /> <!--#include virtual="embed.html" --><br /> <!--#exec cmd="test.pl" --><br /> <!--#exec cmd="dir" --><br /> </body> </html> 2)、embed.html 复制代码 代码如下: <html> <head> <title>embed html</title> </head> <body> This is the content from embed.html </body> </html> 3)、test.pl 复制代码 代码如下: #!C:perlbinperl -w use strict; sub print_header() sub print_footer() print_header(); 总结: 您可能感兴趣的文章:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |