- 准备好已经安装好nginx的Linux服务器
- 测试是否能够访问成功
- 将我们准备的图片放到一个指定的地址
这里/opt/ormis/images是一个基本路径,里面包含各种类型的图片,比如: - 配置nginx的nginx.conf文件
完整的nginx.conf文件
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location /images/ { root /opt/ormis/; autoindex on; } location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
解释:
1)root则是将images映射到/opt/ormis/images/
2)autoindex on便是打开浏览功能。 - 保存nginx.conf配置,使用下面命令刷新配置
进入到/usr/local/nginx/ 目录下,执行sbin/nginx -s reload - 使用浏览器访问图片
使用Nginx搭建图片服务器
最新推荐文章于 2024-12-02 08:23:02 发布