900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Nginx部署静态页面及引用图片有效访问的两种方式

Nginx部署静态页面及引用图片有效访问的两种方式

时间:2024-01-16 19:17:09

相关推荐

Nginx部署静态页面及引用图片有效访问的两种方式

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;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。