1. 程式人生 > >Nginx之使用nginx搭建簡單的文件服務器

Nginx之使用nginx搭建簡單的文件服務器

oot bubuko 文件 配置 format 單擊 cati nec 文件大小

  使用nginx可以搭建簡單文件服務器

  安裝nginx(不詳述)  

  修改配置文件

/usr/local/nginx/conf/nginx.conf

  

user  root;
 /usr/local/nginx/conf/conf.d/file.conf

  

worker_processes 1; #error_log logs/error.log; #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; keepalive_timeout 65; include ./conf.d/*.conf; }

  文件配置文件

autoindex on;# 顯示目錄
autoindex_exact_size on;# 顯示文件大小
autoindex_localtime on;# 顯示文件時間
server {
    listen       80;
    server_name  172.16.90.13;
    root         /data/file;
}

  創建根目錄文件夾並且放入幾個文件

  web頁面訪問查看,單擊文件即可下載

技術分享圖片

Nginx之使用nginx搭建簡單的文件服務器