yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
$ wget http://nginx.org/download/nginx-1.16.1.tar.gz
$ useradd -d /home/nginx -m nginx
$ tar -zxvf nginx-1.16.1.tar.gz
$ cd nginx-1.16.1
$ ./configure --user=nginx --group=nginx --prefix=/home/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream
$ make
$ make install
$ 配置文件服务器
server {
listen 端口;
server_name localhost;
access_log /home/nginx/download.log;
charset utf-8;
root /home/ftp;
location / {
autoindex_exact_size off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_connect_timeout 1200;
proxy_read_timeout 1200;
proxy_send_timeout 6000;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
autoindex on;
limit_rate_after 25m; ## 达到最大带宽时开始限制
limit_rate 25m; ## 带宽限制
if ($request_filename ~* ^.*?\.(jar|txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
add_header Content-Disposition: 'attachment;';
}
}
}
--------------------------启动/校验/停止----------------
访问地址:http://IP:端口/
$./nginx -t
$./nginx -c /home/nginx/conf/nginx.conf
$./nginx -s stop
原文:https://www.cnblogs.com/virtulreal/p/11877252.html