sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install openssl
将nginx及upload、progress第三方库上传或下载至ubuntu服务器
Xshell 文件传输sz/rz
http://nginx.org/en/download.html
https://github.com/fdintino/nginx-upload-module#upload_pass
https://www.nginx.com/resources/wiki/modules/upload_progress/
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --add-module =‘upload模块目录’ --add-module = ‘progress模块目录’
参数说明:
–prefix 用于指定nginx编译后的安装目录
–add-module 为添加的第三方模块
–with…_module 表示启用的nginx模块,如此处启用了好几个模块
make
make install
创建一个nginx软链接
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
查看配置文件是否正确:nginx -t
启动:nginx
重启:nginx -s reload
停止:nginx -s stop或者是通过kill nginx进程号
查看版本及编译参数:nginx –V
在已安装的nginx上进行添加模块
1)备份配置文件
2)执行nginx -V查看已编译参数,./configure + 已编译参数 +添加新增模块;
3)make 编译完后,把objs中的nginx替换掉之前的nginx文件,然后重启nginx就行了;
如果执行下一步的install,会导致之前安装的nginx被覆盖,比如之前配置好的nginx.conf文件等
user root;
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;
client_max_body_size 100m;#设置上传文件的最大值
upload_progress proxied 1m;#设置连接存放跟踪信息的最大值
#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 10888;
server_name localhost;
charset utf-8;
#charset koi8-r;
#access_log logs/host.access.log main;
#文件下载路径配置
location /download {
alias /usr/local/nginx/html/download;
if ($request_filename ~* ^.*?\.(txt|pdf|doc|xls)$){
add_header Content-Disposition "attachment;";
}
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
#网页部署
location /cloud {
alias /cloud_ui;
index index.html;
}
#上传进度部署
location ^~ /progress{
report_uploads proxied;
}
#文件上传配置
location /upload/ {
upload_pass @test;
upload_store /usr/local/nginx/tmp 1;
upload_store_access user:r;
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
upload_pass_form_field "^.*$";
upload_cleanup 400 404 499 500-505;
track_uploads proxied 30s;
}
#上传文件接口转发
location @test{
proxy_pass http://localhost:8080;
}
#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;
# }
#}
}
参考链接:
https://blog.csdn.net/zlxtk/article/details/80995955
https://blog.csdn.net/qq_54947566/article/details/116327207