资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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

1.首先明确,只能够指定某个确定的目录,支持cgi,即运行该目录执行cgi程序;否则不太安全。
寻找:成都服务器托管

网站建设公司,为您提供网站建设,网站制作,网页设计及定制网站建设服务,专注于成都企业网站定制,高端网页制作,对成都石牌坊等多个行业拥有丰富的网站建设经验的网站建设公司。专业网站设计,网站优化推广哪家好,专业成都网站推广优化,H5建站,响应式网站。
复制代码代码如下:

#
# "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#

AllowOverride all
Options all
Order allow,deny
Allow from all

设置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.
设置cgi脚本的后缀,寻找:成都服务器托管

复制代码代码如下:

#
# 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)
关于什么是SSI以及什么是shtml,请参看本站的其他两篇文章。
使用SSI可以实现html的动态嵌入内容,可以为一下SSI的命令,甚至是系统返回结果,以及比较常用的调用Perl程序(尤其是perl的cgi返回结果)

1. 配置Apache:
1)首先找到:成都服务器托管


复制代码代码如下:

#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml

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

复制代码代码如下:

#
# "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#

AllowOverride all
Options all
Order allow,deny
Allow from all

从Directory开始进行修改:
首先指定到自己的目录,这里是"E:/Website_Field/shtml";
然后设置各个选项如上:成都服务器托管


复制代码代码如下:

AllowOverride all
Options all
Order allow,deny
Allow from all

完后重启Apache应该就可以了。成都网站建设公司


2. 关于Apache支持的SSI指令

3. 一个使用SSI的shtml页面实例:
1)、index.shtml


复制代码代码如下:



shtml



This file last modified


Today is









2)、embed.html


复制代码代码如下:



embed html


This is the content from embed.html


3)、test.pl


复制代码代码如下:

#!C:\perl\bin\perl -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支持cgi、SSI、shtml的配置方法
本文链接:http://cdkjz.cn/article/sipdd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220