# 安装以下依赖
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libssl-dev
# 下载源码包
wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
wget https://nginx.org/download/nginx-1.20.2.tar.gz
# 编译配置选项
./configure \
--prefix=/opt/app/nginx \
--sbin-path=/opt/app/nginx/sbin/nginx \
--conf-path=/opt/app/nginx/conf/nginx.conf \
--error-log-path=/opt/app/nginx/logs/error.log \
--http-log-path=/opt/app/nginx/logs/access.log \
--pid-path=/opt/app/nginx/nginx.pid \
--lock-path=/opt/app/nginx/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/opt/app/nginx/tmp/client/ \
--http-proxy-temp-path=/opt/app/nginx/tmp/proxy/ \
--http-fastcgi-temp-path=/opt/app/nginx/tmp/fcgi/ \
--http-uwsgi-temp-path=/opt/app/nginx/tmp/uwsgi \
--http-scgi-temp-path=/opt/app/nginx/tmp/scgi \
--with-pcre \
--with-openssl=/opt/source/openssl-1.1.1o \
--with-http_addition_module
# 编译和安装
make && make install
# 美化配置及视频格式支持
./configure \
--prefix=/opt/app/nginx \
--sbin-path=/opt/app/nginx/sbin/nginx \
--conf-path=/opt/app/nginx/conf/nginx.conf \
--error-log-path=/opt/app/nginx/logs/error.log \
--http-log-path=/opt/app/nginx/logs/access.log \
--pid-path=/opt/app/nginx/nginx.pid \
--lock-path=/opt/app/nginx/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/opt/app/nginx/tmp/client/ \
--http-proxy-temp-path=/opt/app/nginx/tmp/proxy/ \
--http-fastcgi-temp-path=/opt/app/nginx/tmp/fcgi/ \
--http-uwsgi-temp-path=/opt/app/nginx/tmp/uwsgi \
--http-scgi-temp-path=/opt/app/nginx/tmp/scgi \
--with-pcre \
--with-openssl=/opt/source/openssl-1.1.1k \
--with-http_flv_module \
--with-http_dav_module \
--with-http_stub_status_module --with-http_realip_module \
--with-ngx_http_sticky_module \
--add-module=/opt/source/nginx-1.19.9/other/nginx-goodies-nginx-sticky-module-ng-08a395c66e42 \
--add-module=/opt/source/nginx-1.19.9/other/nginx_mod_h264_streaming-2.2.7 \
--add-module=/opt/source/nginx-1.19.9/other/ngx-fancyindex-0.5.2 \
--with-http_addition_module
## nginx-goodies-nginx-sticky-module-ng-08a395c66e42
wget https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/08a395c66e42.zip
## nginx_mod_h264_streaming-2.2.7
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
## ngx-fancyindex-0.5.2
https://github.com/aperezdc/ngx-fancyindex
## Nginx-Fancyindex-Theme
https://github.com/Naereen/Nginx-Fancyindex-Theme
# nginx 文件下载配置
server {
listen 82;
server_name 127.0.0.1;
charset utf-8,gbk;
root /Users/fengye/data;
location ~ \.mp4$ {
mp4;
}
location /theme {
alias /opt/app/nginx/html/theme/;
}
location / {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
fancyindex on; # Enable fancy indexes.
fancyindex_exact_size off; # Output human-readable file sizes.
fancyindex_localtime on;
fancyindex_header /theme/flat-theme/header.html;
fancyindex_footer /theme/flat-theme/footer.html;
fancyindex_ignore "fancydark";
fancyindex_name_length 255;
if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
add_header Content-Disposition: 'p_w_upload;';
}
}
}