网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

如何让Apache支持cgi、SSI和shtml

这篇文章主要介绍“如何让Apache支持cgi、SSI和shtml”,在日常操作中,相信很多人在如何让Apache支持cgi、SSI和shtml问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何让Apache支持cgi、SSI和shtml”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

醴陵网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。创新互联成立与2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

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.
    #
   
        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和shtml”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


本文题目:如何让Apache支持cgi、SSI和shtml
标题网址:http://bjjierui.cn/article/gcgehs.html

其他资讯