Ubuntu 14.04 LTS Apache2 开启 SSI 功能

SSI (Server Side Include)的 html 文件扩展名 (.shtml), 通常称为"服务器端嵌入"或者叫"服务器端包含"

说白了就是类似其他语言如 PHP include 引入其他文件,SSI 是通过配置服务器,一个静态 html 文件引入另一个 html 文件的功能

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

1、如果 Ubuntu中还未安装APACHE服务器,请先安装

sudo apt-get install apache2


2、创建符号链接


sudo ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled


3、打开刚刚创建好的软连接配置文件

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>


4、重启 apache2

启动:service apache2 start 
重启:service apache2 restart
停止:service apache2 stop


5、测试

1.html

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


2.html

<h1>
Hello World!
</h1>

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


参考文章:http://blog.csdn.net/justflyhigh/article/details/8593792

http://www.linuxidc.com/Linux/2007-11/8828.htm


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值