码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置ssi

时间:2019-06-12 18:13:57      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:error   文件中   listen   发送   命令   工作   ast   web服务器   fast   

一、什么是SSI

SSI:Server Side Include,是一种基于服务端的网页制作技术,大多数(尤其是基于Unix平台)的web服务器如Netscape Enterprise Server等均支持SSI命令。

它的工作原因是:在页面内容发送到客户端之前,使用SSI指令将文本、图片或代码信息包含到网页中。对于在多个文件中重复出现内容,使用SSI是一种简便的方法,将内容存入一个包含文件中即可,不必将其输入所有文件。通过一个非常简单的语句即可调用包含文件,此语句指示 Web 服务器将内容插入适当网页。而且,使用包含文件时,对内容的所有更改只需在一个地方就能完成。

二、如何在nginx上配置SSI

需要的选项主要是以下三个:

ssi: 默认值off,启用ssi时将其设为on
ssi_silent_errors: 默认值off,开启后在处理SSI文件出错时不输出错误提示"[an error occurred while processing the directive]"。
ssi_types: 默认是text/html,所以如果需支持html,则不需要设置这句,如果需要支持shtml则需要设置:ssi_types text/shtml

三个参数可以放在http, server或location作用域下。

三、配置用例

server {
        listen       80;
        server_name  www.fn.com;

        access_log   /var/log/nginx/www.fn.log  main;
        root  /home/www.fn.com/public; 
        index  index.html index.htm index.php;

        location / {
             ssi on;
                ssi_silent_errors on;
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php {
                root  /home/www.fn.com/public;
                fastcgi_index  index.php;
                fastcgi_pass   unix:/tmp/php-cgi.sock;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

nginx配置ssi

标签:error   文件中   listen   发送   命令   工作   ast   web服务器   fast   

原文地址:https://www.cnblogs.com/cyleon/p/11011112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!