讓Apache支持cgi、SSI、shtml的配置方法
1.首先明確,只能夠指定某個確定的目錄,支持cgi,即運行該目錄執(zhí)行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>
設(shè)置Directory為可以執(zhí)行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.
設(shè)置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
設(shè)置后綴如.cgi, .pl等等,任意可以想到的,但是避免使用已有的如.html, .asp, .php等
注意:設(shè)置支持cgi的目錄之后,該目錄下的內(nèi)容及子目錄的內(nèi)容都可以執(zhí)行。
配置Apache支持SSI,即服務(wù)器端解析的server-parsed html(shtml)
關(guān)于什么是SSI以及什么是shtml,請參看本站的其他兩篇文章。
使用SSI可以實現(xiàn)html的動態(tài)嵌入內(nèi)容,可以為一下SSI的命令,甚至是系統(tǒng)返回結(jié)果,以及比較常用的調(diào)用Perl程序(尤其是perl的cgi返回結(jié)果)
1. 配置Apache:
1)首先找到:
#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml
去掉后兩行之前的#號;
2)同時需要指定那個在哪個目錄內(nèi)支持這種解析,尋找:
#
# "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";
然后設(shè)置各個選項如上:
AllowOverride all
Options all
Order allow,deny
Allow from all
完后重啟Apache應(yīng)該就可以了。
2. 關(guān)于Apache支持的SSI指令,可以參考如下介紹:
http://www.dbjr.com.cn/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:\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();
總結(jié):
設(shè)置Apache支持cgi和支持SSI的時候有個相同的部分,設(shè)置目錄Directory,而且需要設(shè)置為相同的。
因此,如果單使用ssi的話,可以按照ssi的設(shè)置進行配置,將shtml等放置到設(shè)置的目錄下;
如果已設(shè)置Apache支持cgi,只需要打開ssi,同時將shtml等文件放置到cgi的目錄中即可。
相關(guān)文章
新版ubuntu20.04 使用root用戶登錄系統(tǒng)的詳細(xì)教程
這篇文章主要介紹了新版ubuntu20.04 使用root用戶登錄系統(tǒng)的詳細(xì)教程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-08-08Win10 + Ubuntu 16.04雙系統(tǒng)完美安裝教程【詳細(xì)】
這篇文章主要介紹了Win10 + Ubuntu 16.04雙系統(tǒng)完美安裝教程,本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10Linux/CentOS系統(tǒng)同步網(wǎng)絡(luò)時間的2種方法詳解
我們知道Windows系統(tǒng)下可以同步網(wǎng)絡(luò)時間,那么Linux系統(tǒng)下有沒有相同的功能呢,今天為大家介紹2Linux系統(tǒng)下同步網(wǎng)絡(luò)時間的方法2018-10-10使用iptable和Firewalld工具來管理Linux防火墻連接規(guī)則
今天小編就為大家分享一篇關(guān)于使用iptable和Firewalld工具來管理Linux防火墻連接規(guī)則的文章,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-09-09UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY
這篇文章主要介紹了UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07