让Apache支持cgi、SSI、shtml的配置方法

2019-01-17 04:32:12刘景俊

去掉后两行之前的#号;
2)同时需要指定那个在哪个目录内支持这种解析,寻找:


  #
    # "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指令,可以参考如下介绍:
//www.jb51.net/tools/onlinetools/apache-chs/howto/ssi.html

3. 一个使用SSI的shtml页面实例:
1)、index.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()
{
    print "This is Header function! ";  
}

sub print_footer()
{
    print "This is Footer function! ";  
}

print_header();
print_footer();

总结:
设置Apache支持cgi和支持SSI的时候有个相同的部分,设置目录Directory,而且需要设置为相同的。
因此,如果单使用ssi的话,可以按照ssi的设置进行配置,将shtml等放置到设置的目录下;
如果已设置Apache支持cgi,只需要打开ssi,同时将shtml等文件放置到cgi的目录中即可。

您可能感兴趣的文章:

Apache下开启SSI配置使html支持include包含的方法配置Apache支持shtml(SSI)的方法apache SHTML网页SSI使用详解IIS SHTML支持设置方法(SSI)SSI技术—SHTML的解释(生成静态时用的最火)HTML静态页面引入公共html文件(ssi服务器端指令详解)