加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Apache > 正文

debian系统下apache2开启ssi功能

发布时间:2020-12-13 19:23:43 所属栏目:Apache 来源:网络整理
导读:SSI (Server Side Include)的 html 文件扩展名 (.shtml),通常称为"服务器端嵌入"或者叫"服务器端包含" 说白了就是类似其他语言如 PHP include 引入其他文件,SSI 是通过配置服务器,一个静态 html 文件引入另一个 html 文件的功能 被包含文件与父文件存在

SSI (Server Side Include)的 html 文件扩展名 (.shtml),通常称为"服务器端嵌入"或者叫"服务器端包含"
说白了就是类似其他语言如 PHP include 引入其他文件,SSI 是通过配置服务器,一个静态 html 文件引入另一个 html 文件的功能

被包含文件与父文件存在于相同目录中
<!-- #include file = "index.html" -->
被包含文件位于脚本虚拟目录中
<!-- #include virtual = "/scripts/tools/index.html" -->

1.加载mod_include.so模块

创建符号链接
sudo ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled
或者直接拷贝
cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/include.load


2.打开刚刚创建好的软连接配置文件
sudo vi /etc/apache2/mods-enabled/include.load

添加以下内容

# Depends: mime
LoadModule include_module /usr/lib/apache2/modules/mod_include.so

# 上面内容是已有的,添加下面内容
<Directory /var/www/html/>
Options Indexes FollowSymLinks Includes
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/,but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
AddType text/html .shtml .html #这两个是主要的配置文件
AddOutputFilter INCLUDES .shtml .html #加上 .html 意思是可以 include .html 文件
</Directory>


3.重启apache2
启动:service apache2 start?
重启:service apache2 restart
停止:service apache2 stop

4.测试

1.html

<html>
<body>
<!--#include file="2.html"-->
</body>
</html>


2.html
<h1>Hello World!</h1>

浏览器运行 1.html 成功显示 Hello World! 说明配置成功

?

done!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读