赞
踩
参考总结:3种实现文件下载和上传功能的服务器搭建配置
一、nginx
二、miniserve
三、nodejs
一、nginx
效果如下(暂时只有文件下载功能,文件上传功能还没有配置)
Windows下
1.1下载
1.2解压
1.3运行
运行nginx.exe,在浏览器中输入localhost,出现下图表示成功
1.4配置nginx
nginx配置文件详解可以百度一下,太长就不写了,就给个我自己的配置
nginx默认端口是80,可以更改避免出现端口占用。location配置较为关键,我配了两个
局域网内浏览器输入:http://localhost/downloadtest/ http://localhost/apk/即可访问实现文件下载
-
- #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 utf-8;
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- #location / {
- # root html;
- # index index.html index.htm;
- #}
-
- location /apk {
- root F:\\DownloadTest;
- autoindex on;
- autoindex_exact_size off;
- autoindex_localtime on;
- }
- location /downloadtest {
- root F:\\DownloadTest;
- autoindex on;
- autoindex_exact_size off;
- autoindex_localtime on;
- }
-
- #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

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。