一、SSI解释

SSI是一种类似于ASP的基于服务器的网页制作技术。将内容发送到浏览器之前,可以使用“服务器端包含 (SSI)”指令将文本、图形或应用程序信息包含到网页中。例如,可以使用 SSI 包含时间/日期戳、版权声明或供客户填写并返回的表单。对于在多个文件中重复出现的文本或图形,使用包含文件是一种简便的方法。将内容存入一个包含文件中即可,而不必将内容输入所有文件。通过一个非常简单的语句即可调用包含文件,此语句指示 Web 服务器将内容插入适当网页。而且,使用包含文件时,对内容的所有更改只需在一个地方就能完成。

因为包含 SSI 指令的文件要求特殊处理,所以必须为所有 SSI 文件赋予 SSI文件扩展名。默认扩展名是 .stm、.shtm 和 .shtml

二. apache配置
修改Apache配置文件httpd.conf
#确认加载include.so模块,将注释去掉:
LoadModule include_module libexec/apache2/mod_include.so

#AddType部分去掉这两段注释:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

#Directory目录权限里面找到
Options Indexes FollowSymLinks
#增加Includes修改为:
Options Indexes FollowSymLinks Includes
重新启动Apache
apachectl server restart
二. nginx配置置
ssi 指令
语法:ssi [ on | off ]
默认值:ssi off
配置段段:http, server, location, if
启用SSI处理。

注意如果启用SSI,那么Last-Modified头和Content-Length头不会传递。

ssi_silent_errors 指令
语法:ssi_silent_errors [on|off]
默认值:ssi_silent_errors off
配置段:http, server, location

如果在处理SSI的过程中出现“[an error occurred while processing the directive]”错误,禁止将其输出。

ssi_types 指令
语法:ssi_types mime-type [mime-type …]
默认值:ssi_types text/html
配置段:http, server, location

默认只解析text/html类型,这个参数可以指定其他的MIME类型

ssi_value_length
语法:ssi_value_length length
默认值:ssi_value_length 256
配置段:http, server, location

定义允许SSI使用的参数值的长度。

在nginx下做如下设置,在http段添加:

ssi on;
ssi_silent_errors off;
ssi_value_length 1024;
ssi_types text/shtml;
location / {
    ssi on;
    ssi_silent_errors off;
    ssi_value_length 1024;
    ssi_types text/shtml;
}
location ~* \.shtml$ {
    ssi on;
    ssi_silent_errors off;
    ssi_value_length 1024;
    ssi_types text/shtml;
}

原文来自:http://www.hhailuo.com/archives/18407

本文地址:https://www.linuxprobe.com/nginx-apache-nginx.html编辑:xiangping wu,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/