Windows安装nginx
下载 解压后运行目录中的可运行程序nginx.exe,浏览器访问http://{localIP} 如http://127.0.0.1即可看到如下界面![](https://static.oschina.net/uploads/img/201707/02000714_dNE9.png)
location / { #静态文件目录 root E:\code\dist; index index.html index.htm; }执行如下命令用于检测配置文件是否有误:
nginx -t若配置正确则输出如下结果:
![](https://static.oschina.net/uploads/img/201707/02000714_laiY.png)
nginx -s reload再次访问http://ip即可看到自己的静态首页
SSI
ssi(server side include).即在html或其他标记语言页面中使用include标签属性引入其他页面。我们通常在前端界面中为了使一部分代码能够公用,例如头部和底部代码公用。该文主要讲述的是使用nginx ssi模块解决这样的需求。SSI配置
如下所示开启ssi功能,以及SSI文件格式:location / { ssi on; ssi_last_modified on; ssi_min_file_chunk 1k; ssi_silent_errors off; ssi_types text/html; ssi_value_length 256; root /var/www; index index.html }
代码结构
![](https://static.oschina.net/uploads/img/201707/02000714_LE2l.png)
SSI-SAMPLE SSI-SAMPLE