Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save 21d5/2a381e35ef6155b3f9e737c22c0e04e1 to your computer and use it in GitHub Desktop.

Select an option

Save 21d5/2a381e35ef6155b3f9e737c22c0e04e1 to your computer and use it in GitHub Desktop.

Revisions

  1. @excid3 excid3 created this gist Jun 20, 2018.
    30 changes: 30 additions & 0 deletions dynamic-nginx-module-ubuntu-18.04.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # Install dependencies that nginx was originally compiled with
    sudo apt install libperl-dev libgeoip-dev libgd-dev

    # Get the nginx source
    wget https://nginx.org/download/nginx-1.14.0.tar.gz
    tar zxf nginx-1.14.0.tar.gz

    # Get the module source
    wget https://github.com/fdintino/nginx-upload-module/archive/master.zip
    unzip master.zip

    # Find the args the existing nginx was compiled with, use these later in the config line
    nginx -V

    # If you don't do this, you'll get an error when you try to use the module like so:
    # module "/usr/lib/nginx/modules/ngx_http_upload_module.so" is not binary compatible in /etc/nginx/modules-enabled/50-mod-http-upload.conf:1

    # Compile the dynamic module
    cd nginx-1.14.0
    ./configure --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-mcUg8N/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=../nginx-upload-module-master
    make modules

    # Move the module to the nginx modules folder
    sudo mv objs/ngx_http_upload_module.so /usr/lib/nginx/modules

    # Enable the module
    echo 'load_module /usr/lib/nginx/modules/ngx_http_upload_module.so;' | sudo tee /etc/nginx/modules-enabled/50-mod-http-upload.conf

    # Check if it is setup correctly
    sudo nginx -t