这里有新鲜出炉的 Nginx 中文文档,程序狗速度看过来!
Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本 0.1.0 发布于 2004 年 10 月 4 日。其将源代码以类 BSD 许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
这篇文章主要介绍了 window 下使用 nginx 提供文件下载服务器配置, 需要的朋友可以参考下
1. 前言
当我们希望分享自己的文件时,有多种方式,局域网可以采用共享,rtx 传输,qq 传输,发送到邮箱,直接 u 盘拷贝等等。但最简单的就是开启本地服务器,其他电脑通过网页的方式直接下载,这里介绍使用 nginx 作为服务器进行下载
2. 步骤
1. 下载 nginx http://nginx.org/en/download.html 目前稳定版本为 1.80 解压到一个目录
2. 修改配置文件
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 8080;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- #root html;
- #index index.html index.htm;
- if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
- add_header Content-Disposition: 'attachment;';
- }
- }
- #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;
- }
- }
- }
3. 在 nginx 目录下的 html 中建立目录 test 和 test.rar 文件
4. 打开命令行切换到 nginx 目录
4.1 测试脚本 nginx -t
4.2 开启服务器 start nginx
4.3 打开浏览器 http://localhost:8080/test/test.rar 应该弹出另存为对话框
4.4 关闭服务器 nginx -s quit
来源: http://www.phperz.com/article/17/0825/344299.html