部署一个静态页面做测试


  • 文件路径是这样的
1
2
3
4
5
6
7
.
└── background
├── images
│ ├── 1.jpg
│ ├── 2.jpg
│ └── 3.jpg
└── index.html
  • index.html 中的路径是这样的
1
style="background-image:url('/images/1.jpg')"
  • /etc/nginx/nginx.conf 是这样的
1
2
3
4
5
6
7
8
9
10
11
12
13
server {
listen 80;
server_name background.wxy.email; # 域名/ip
charset utf-8;
location / {
root /home/www/background; # html存储路径
index index.html; # html名称
}
location /images/ {
alias /home/www/background/images/; # 图片存储路径
autoindex on;
}
}
  • 修改文件夹权限
1
sudo chmod 777 -R /home/www/background/
  • 启动 / 重启nginx
1
2
sudo service nginx start  # 启动
sudo service nginx reload #重启