您好,登錄后才能下訂單哦!
這篇文章主要介紹“如何讓Apache支持cgi、SSI和shtml”,在日常操作中,相信很多人在如何讓Apache支持cgi、SSI和shtml問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何讓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.
設置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.
#
<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頁面實例:
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:\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”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。