1.进入官网下载nginx压缩包,解压后目录如下
2.在解压后的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 8089; server_name localhost; #charset utf-8; #access_log logs/host.access.log main; #添加博客的代码 location ~ .*\.(gif|jpg|jpeg|png)$ { expires 24h; root g:/images/;#指定图片存放路径 access_log g:/images/log;#图片路径 proxy_store on; proxy_store_access user:rw group:rw all:rw; proxy_temp_path g:/images/;#图片路径 proxy_redirect off; proxy_set_header host 127.0.0.1; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 1280k; proxy_connect_timeout 900; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 40k; proxy_buffers 40 320k; proxy_busy_buffers_size 640k; proxy_temp_file_write_size 640k; if ( !-e $request_filename) { proxy_pass http://169.254.140.133:8089; #代理访问地址 } } location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the php scripts to apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param script_filename /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # 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; # } #} }
3.点击绿色的nginx.exe图标,启动服务器,在任务管理器看到如下,则启动成功
4.在浏览器中输入http://127.0.0.1:8089可以看到
5.在g:/images/下,放一个图片,在浏览器地址栏输入http://127.0.0.1:8089/img.jpg,就可以访问到服务器上的图片
以上是windows中怎么使用Nginx搭建图片服务器的详细内容。更多信息请关注PHP中文网其他相关文章!

nginxserveswebcontentandactsasareverseproxy,loadBalancer和more.1)效率高效的servesstaticContentLikeHtmlandImages.2)itfunctionsasareverseproxybalancer,and andginxenhanceperforfforfforfforfforfforffrenfcaching.4)

NGINXUnit通过动态配置和多语言支持简化应用部署。1)动态配置无需重启服务器即可修改。2)支持多种编程语言,如Python、PHP、Java。3)采用异步非阻塞I/O模型,提升高并发处理性能。

NGINX起初解决C10K问题,现已发展为处理负载均衡、反向代理和API网关的全能选手。1)它以事件驱动和非阻塞架构闻名,适合高并发。2)NGINX可作为HTTP和反向代理服务器,支持IMAP/POP3。3)其工作原理基于事件驱动和异步I/O模型,提升了性能。4)基本用法包括配置虚拟主机和负载均衡,高级用法涉及复杂负载均衡和缓存策略。5)常见错误包括配置语法错误和权限问题,调试技巧包括使用nginx-t命令和stub_status模块。6)性能优化建议包括调整worker参数、使用gzip压缩和

Nginx常见错误的诊断与解决方法包括:1.查看日志文件,2.调整配置文件,3.优化性能。通过分析日志、调整超时设置和优化缓存及负载均衡,可以有效解决404、502、504等错误,提高网站稳定性和性能。

nginxunitischosenfordEployingApplicationsDuetoItsflexibility flexibility,sisofuse,andability tohandledynamicApplications.1)itupportsmultProgramprogrogminglanguagesLikeLikeLikePython,php,node.js,andjava.2)

NGINX可用于服务文件和管理流量。1)配置NGINX服务静态文件:定义监听端口和文件目录。2)实现负载均衡和流量管理:使用upstream模块和缓存策略优化性能。

NGINX适合处理高并发和静态内容,Apache适用于动态内容和复杂URL重写。1.NGINX采用事件驱动模型,适合高并发。2.Apache使用进程或线程模型,适用于动态内容。3.NGINX配置简单,Apache配置复杂但更灵活。

NGINX和Apache各有优势,选择取决于具体需求。1.NGINX适合高并发,部署简单,配置示例包括虚拟主机和反向代理。2.Apache适用于复杂配置,部署同样简单,配置示例包括虚拟主机和URL重写。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

WebStorm Mac版
好用的JavaScript开发工具

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

SublimeText3汉化版
中文版,非常好用