Skip to content

Instantly share code, notes, and snippets.

@peppiii
Last active May 26, 2020 17:29
Show Gist options
  • Select an option

  • Save peppiii/e924776a4f4273ea88374ed29c6d5a09 to your computer and use it in GitHub Desktop.

Select an option

Save peppiii/e924776a4f4273ea88374ed29c6d5a09 to your computer and use it in GitHub Desktop.
Installation Nginx-build custom

installation nginx-build

Download nginx source code

$ cd /usr/local
$ sudo Wget http://nginx.org/download/nginx-1.18.0.tar.gz
$ sudo tar -xzcf nginx-1.18.0.tar.gz
$ sudo mv nginx-1.18.0 nginx

Installation Dependecies and users

$ sudo apt-get install unzip -y
$ sudo apt-get install gcc -y
$ sudo apt install libgd-dev -y
$ sudo apt-get install libgeoip-dev
$ sudo adduser www

Installation module nginx

$ cd /usr/src
$ sudo git clone git://github.com/vozlt/nginx-module-vts.git
$ sudo git clone https://github.com/alibaba/nginx-http-concat.git
$ sudo git clone https://github.com/cubicdaiya/ngx_dynamic_upstream.git
$ sudo git clone https://github.com/ZigzagAK/ngx_dynamic_healthcheck.git
$ sudo git clone https://github.com/FRiCKLE/ngx_cache_purge.git

PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules.

$ sudo https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
$ sudo tar -zxf pcre-8.44.tar.gz
$ sudo mv pcre-8.44 pcre

zlib – Supports header compression. Required by the NGINX Gzip module.

$ sudo wget http://zlib.net/zlib-1.2.11.tar.gz
$ sudo tar -zxf zlib-1.2.11.tar.gz
$ sudo mv zlib-1.2.11 zlib

OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.

$ sudo wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.1.tar.gz
$ sudo tar -zxf libressl-2.8.1.tar.gz
$ sudo mv libressl-2.8.1 libressl

Compile Nginx

$ cd /usr/local/nginx/
$ sudo ./configure --prefix=/usr/local/nginx --build=name --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --with-openssl=/usr/src/libressl --with-pcre=/usr/src/pcre --with-zlib=/usr/src/zlib --with-http_ssl_module --with-http_v2_module --with-file-aio --with-http_flv_module --with-http_gzip_static_module --with-http_sub_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_geoip_module --with-http_image_filter_module --with-debug --with-stream --user=www --group=www --add-module=/usr/src/nginx-module-vts --add-module=/usr/src/ngx_dynamic_upstream --add-module=/usr/src/ngx_dynamic_healthcheck --add-module=/usr/src/ngx_cache_purge --add-module=/usr/src/nginx-http-concat
$ sudo make install

Create Systemd

$ sudo nano /etc/systemd/system/nginx.service

copy & paste Config

[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment