- 去官网下载最新的nginx:http://nginx.org/en/download.html
- 将压缩包解压,将conf下的nginx.conf复制一份,修改以下标记内容。
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; #修改部分开始 server { # 监听端口 listen 3333; server_name localhost; # 本地存放图片位置 location /{ root C:/images; } # 异常页面配置 error_page 400 403 404 500 502 503 /50x.html; location = /50x.html { root html; } } #修改部分结束 # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } - 在C:/images目录下放一张图片,比如1.jpg
- 切换至bin目录,用命令【start nginx】启动nginx。切换至bin目录,用命令【start nginx】启动nginx,访问:localhost:3333/1.jpg

Windows环境下利用nginx作为图片服务器
最新推荐文章于 2021-12-04 23:33:30 发布
本文介绍如何从官网下载并配置Nginx,通过修改nginx.conf文件设置服务器监听端口,指定本地图片存储路径,及错误页面配置。在C盘images目录放置图片,启动Nginx后即可通过localhost:3333访问。
4583

被折叠的 条评论
为什么被折叠?



