nginx安装百度一下有很多,直接正题:

静态文件目录结构

file#文件位置 /home/service/file/

  css

  js

  images

  html

  fonts

配置nginx.conf核心代码(html引用图片用的是相对路径)

第一种:实用型

server {
listen 80;
server_name localhost;

location ^~/image{
   root /home/;#图片路径
}

location / {
  root /home/service/file/html;
  index home.html;
}

第二种:简单易懂

server {
listen 80;
server_name localhost;

location / {
  root /home/service/file/;#执行HTML和image的父级路径
  index  html/home.html;
}

Nginx部署静态页面及引用图片有效访问的两种方式的更多相关文章

  1. 使用 Nginx 部署静态页面

    Nginx 介绍 Nginx 是俄罗斯人编写的十分轻量级的 HTTP 服务器, Nginx,它的发音为「engine X」,是一个高性能的 HTTP 和反向代理服务器,同时也是一个 IMAP/ POP ...

  2. 转载:Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式

    Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式 出自:http://www.cnblogs.com/top5/archive/2012/08/04/2623464.html 关 ...

  3. nginx开启ssl并把http重定向到https的两种方式

    1 简介 Nginx是一个非常强大和流行的高性能Web服务器.本文讲解Nginx如何整合https并将http重定向到https. https相关文章如下: (1)Springboot整合https原 ...

  4. nginx部署静态页面

    1.创建文件存放的目录: 2.vim nginx.conf    找到这个文件然后进入编辑模式 注:进入到文件后:点击a:可以编辑文件, server_name 127.0.0.1;    写上ip或 ...

  5. Nginx反向代理实现会话(session)保持的两种方式 (转)

    http://blog.csdn.net/gaoqiao1988/article/details/53390352 一.ip_hash: ip_hash使用源地址哈希算法,将同一客户端的请求总是发往同 ...

  6. js 实现图片预览的两种方式

    第一种方式:(使用bloburl) 格式为: blob:http://localhost:8080/9d1c3f82-90ff-4891-a1a3-9cb9a9782899 blob:http://l ...

  7. html 指定页面字符集的两种方式

      1.html指定页面字符集的两种方式 方式一: <meta charset="utf-8"> 方式二: <meta http-equiv="Cont ...

  8. 在CentOS 上搭建nginx来部署静态页面网站

    在centOs 上搭建nginx来部署静态页面网站 一.部署服务器环境 nginx:轻量级.高性能的HTTP及反向代理服务器,占用内存少,并发能力强,相比老牌的apache作为web服务器,性能更加卓 ...

  9. 使用Nginx部署静态网站

    这篇文章将介绍如何利用Nginx部署静态网站. 之前写过2篇有关Nginx的文章,一篇是<利用nginx,腾讯云免费证书制作https>,另外一篇是<linux安装nginx> ...

随机推荐

  1. Poj 2488 A Knight's Journey(搜索)

    Background The knight is getting bored of seeing the same black and white squares again and again an ...

  2. 一些js和JQuery的方法

    取值填值: js: get-- innerText, innerHTML, value;  set-- innerText=?, innerHTML=?, value=?; JQuery: get-- ...

  3. web基础(五)Jquery

    jQuery是一个快速的,简洁的javaScript库(占空间特别小,但功能强大!兼容性极强!),这个库里封装了一些方法,使用户能更方便地处理HTMLdocuments.events.实现动画效果,并 ...

  4. [Chapter 3 Process]Practice 3.2 Including the initial parent process, how many processes are created by the program shown in Figure?

    3.2 Including the initial parent process, how many processes are created by the program shown in Fig ...

  5. Struts旅程(六)Struts页面转发控制ActionForward和ActionMapping

    转自:https://blog.csdn.net/lovesummerforever/article/details/19125933

  6. ios AppStore 帐号申请

    App Store最新审核指南 https://developer.apple.com/support/app-review/cn/ http://www.woshipm.com/ucd/144218 ...

  7. sizeof总结

    1.sizeof常用总结 ①与strlen比较       strlen 计算字符串的字符数,以"\0"为结束判断,但不统计结束符.   sizeof 计算数据(数组.变量.类型. ...

  8. java中sleep和join和yield和wait和notify的区别

    1.sleep() 使当前线程(即调用该方法的线程)暂停执行一段时间,让其他线程有机会继续执行,但它并不释放对象锁.也就是说如果有synchronized同步快,其他线程仍然不能访问共享数据.注意该方 ...

  9. 【总结整理】高德LBS开放平台学习

    高德LBS开放平台地址    http://lbs.amap.com/api/javascript-api/guide/create-map/mapstye 概述->示例中心Demo体验-> ...

  10. 使用Java创建JSON数据

    --------------siwuxie095                             工程名:TestCreateJSON 包名:com.siwuxie095.json 类名:Cr ...