部署一个静态页面做测试
-
文件路径是这样的
. └── background ├── images │ ├── 1.jpg │ ├── 2.jpg │ └── 3.jpg └── index.html
-
index.html
中的路径是这样的style="background-image:url('/images/1.jpg')"
-
/etc/nginx/nginx.conf
是这样的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; } }
-
修改文件夹权限
sudo chmod 777 -R /home/www/background/
-
启动 / 重启nginx
sudo service nginx start # 启动 sudo service nginx reload #重启
- 浏览器中输入网址
- 参考项目:http://background.wxy.email/
- 本文链接:时光不写博客-Linux服务器Nginx部署图片