nginx 配置图片服务器 (window版本)
2024-10-18 14:41:25
配置nginx二级域名
①找到配置文件
例如:%nginx_home%/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 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; 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;
# }
#} # Serving Static Content
server {
listen 8080;
server_name localhost;
location /pic/ {
root D:;
}
}
}
红色字部分为新增内容
③重载nginx
%nginx_home%/nginx.exe -s reload
查看帮助
%nginx_home%/nginx.exe -h
nginx version: nginx/1.6.1
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
④放置123.png 到D:\pic 文件夹下
⑤访问 http://localhost:8080/pic/123.png
最新文章
- FASTJSON
- 安装Windows 7
- iOS保存cookie的方法
- JS循环往table中写入行
- 一行代码,让你的应用中UIScrollView的滑动与侧滑返回并存
- win+Nginx+php+mysql 环境配置
- 异步fifo的设计
- 项目解析- JspLibrary - part2
- Phonegap hello world 不容易啊~!
- (C/C++ interview) Static 详解
- 【python】python文件和目录操作方法大全(含实例)
- SQL 中having 和where的区别分析
- MyBatis延迟加载和缓存
- CentOS7从U盘中拷贝文件
- Linux - crontab的创建以及注意事项
- Spring Cloud Config 分布式配置中心【Finchley 版】
- luogu4093 序列 (cdq分治优化dp)
- js 对象及空对象或数组及空数组的判断与比较
- python模块import具体用法
- RowVersion 用法
热门文章
- Mysql 知识(1)
- Haskell语言学习笔记(48)Data.Tuple
- jsp+Servlet+JavaBean+JDBC+MySQL项目增删改查
- C++ 0x 使用 shared_ptr 自动释放, 防止内存泄漏
- 如何将Wav文件做到EXE文件里
- godaddy nginx https 配置
- Mysql Innodb 性能参数设置 https://www.rathishkumar.in/2017/01/how-to-allocate-innodb-buffer-pool-size-in-mysql.html
- 使用python发送邮件
- for of 与 for in 的区别
- hdoj1043 Eight(逆向BFS+打表+康拓展开)