仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 826|回复: 8
打印 上一主题 下一主题

[其他Linux] 给大家带来让Apache撑持cgi、SSI、shtml的设置办法

[复制链接]
谁可相欹 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 14:26:10 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
要明白学好linux不是一件一蹴而就的事,一定要能坚持使用它,特别是在使用初期。
1.起首明白,只可以指定某个断定的目次,撑持cgi,即运转该目次实行cgi程序;不然不太平安。
寻觅:
.代码以下:

#
#"C:/ProgramFiles/ApacheGroup/Apache/cgi-bin"shouldbechangedtowhateveryourScriptAliased
#CGIdirectoryexists,ifyouhavethatconfigured.
#
<Directory"E:/Website_Field/cgi">
AllowOverrideall
Optionsall
Orderallow,deny
Allowfromall
</Directory>


设置Directory为能够实行cgi的目次
2.
寻觅:
.代码以下:

#
#ScriptAlias:Thiscontrolswhichdirectoriescontainserverscripts.
#ScriptAliasesareessentiallythesameasAliases,exceptthat
#documentsintherealnamedirectoryaretreatedasapplicationsand
#runbytheserverwhenrequestedratherthanasdocumentssenttotheclient.
#Thesamerulesabouttrailing"/"applytoScriptAliasdirectivesasto
#Alias.
#
ScriptAlias/cgi-bin/"E:/Website_Field/cgi"


将以后的目次改成和下面的不异。
3.
设置cgi剧本的后缀,寻觅:
.代码以下:

#
#AddHandlerallowsyoutomapcertainfileextensionsto"handlers",
#actionsunrelatedtofiletype.Thesecanbeeitherbuiltintotheserver
#oraddedwiththeActioncommand(seebelow)
#
#Ifyouwanttouseserversideincludes,orCGIoutside
#ScriptAliaseddirectories,uncommentthefollowinglines.
#
#TouseCGIscripts:
#
AddHandlercgi-script.cgi.pl


设置后缀如.cgi,.pl等等,恣意能够想到的,可是制止利用已有的如.html,.asp,.php等
注重:设置撑持cgi的目次以后,该目次下的内容及子目次的内容都能够实行。
设置Apache撑持SSI,即服务器端剖析的server-parsedhtml(shtml)
关于甚么是SSI和甚么是shtml,请参看本站的其他两篇文章。
利用SSI能够完成html的静态嵌进内容,能够为一下SSI的命令,乃至是体系前往了局,和对照经常使用的挪用Perl程序(特别是perl的cgi前往了局)
1.设置Apache:
1)起首找到:
.代码以下:

#
#Touseserver-parsedHTMLfiles
#
AddTypetext/html.shtml
AddHandlerserver-parsed.shtml



往失落后两行之前的#号;
2)同时必要指定谁人在哪一个目次内撑持这类剖析,寻觅:
.代码以下:

#
#"C:/ProgramFiles/ApacheGroup/Apache/cgi-bin"shouldbechangedtowhateveryourScriptAliased
#CGIdirectoryexists,ifyouhavethatconfigured.
#
<Directory"E:/Website_Field/shtml">
AllowOverrideall
Optionsall
Orderallow,deny
Allowfromall
</Directory>


从Directory入手下手举行修正:
起首指定到本人的目次,这里是"E:/Website_Field/shtml";
然后设置各个选项如上:
.代码以下:

AllowOverrideall
Optionsall
Orderallow,deny
Allowfromall


完后重启Apache应当就能够了。
2.关于Apache撑持的SSI指令,能够参考以下先容:
http://www.ckuyun.com/tools/onlinetools/apache-chs/howto/ssi.html
3.一个利用SSI的shtml页面实例:
1)、index.shtml
.代码以下:

<html>
<head>
<title>shtml</title>
</head>
<body>
<!--#configtimefmt="%D"-->
Thisfilelastmodified<!--#echovar="LAST_MODIFIED"--><br/>
<!--#configtimefmt="%A%B%d,%Y"-->
Todayis<!--#echovar="DATE_LOCAL"--><br/>
<!--#includevirtual="embed.html"--><br/>
<!--#execcmd="test.pl"--><br/>
<!--#execcmd="dir"--><br/>
</body>
</html>


2)、embed.html
.代码以下:

<html>
<head>
<title>embedhtml</title>
</head>
<body>
Thisisthecontentfromembed.html
</body>
</html>


3)、test.pl

.代码以下:

#!C:perlinperl-w
usestrict;
subprint_header()
{
print"ThisisHeaderfunction!";
}
subprint_footer()
{
print"ThisisFooterfunction!";
}
print_header();
print_footer();


总结:
设置Apache撑持cgi和撑持SSI的时分有个不异的部分,设置目次Directory,并且必要设置为不异的。
因而,假如单利用ssi的话,能够依照ssi的设置举行设置,将shtml等安排到设置的目次下;
假如已设置Apache撑持cgi,只必要翻开ssi,同时将shtml等文件安排到cgi的目次中便可。

系统做了些什么,这需要时间去掌握,(背命令不是一件好的学习方法,相信我你一定会在你背完之前全部忘光),尽量掌握常用命令;
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-16 08:34

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表