#!/bin/bash
# THIS IS MEANT TO BUILD IT FROM SOURCE AND INSTALLING IT
# http://nginx.org/en/download.html
# UPDATE SYSTEM
apt-get update && apt-get upgrade -y
# GET NGINX MAINLINE FROM SOURCE
wget http://nginx.org/download/nginx-1.17.3.tar.gz
# EXTRACT NGINX
tar -zxvf https://nginx.org/download/nginx-1.17.3.tar.gz
cd nginx-1.17.3/
# INSTALL DEPENDENCIES
apt-get install build-essential
apt-get install libpcre3 libpcre3-dev libpcrecpp0v5 libssl-dev zlib1g-dev
#CONFIGURE NGINX
./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-debug --with-pcre --with-http_ssl_module
#or
./configure \
--sbin-path=/usr/bin/nginx \ #location of the executable
--conf-path=/etc/nginx/nginx.conf \ #path of the configuration file
--error-log-path=/var/log/nginx/error.log \ #where to store the error logs
--http-log-path=/var/log/nginx/access.log \ #where to store the access logs
--with-debug \
--with-pcre \ #use the pcre library for regex
--pid-path=/var/run/nginx.pid #for referencing the process id
--with-http_ssl_module
# BUILD BINARIES
make
# INSTALL NGINX
make install
# RUN NGINX
nginx
#!/bin/bash
# UPDATE SYSTEM
sudo apt-get update && apt-get upgrade -y
# GET NGINX MAINLINE FROM SOURCE
wget https://nginx.org/download/nginx-1.17.3.tar.gz
# EXTRACT NGINX
tar -zxvf https://nginx.org/download/nginx-1.17.3.tar.gz
cd nginx-1.17.3/
# INSTALL DEPENDENCIES
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0v5 libssl-dev zlib1g-dev
#CONFIGURE NGINX
./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-debug --with-pcre --with-http_ssl_module
# BUILD BINARIES
make
# INSTALL NGINX
sudo make install
# RUN NGINX
sudo nginx
sudo apt-get install nginx
#THIS IS MEANT TO COPY KEEP THE CONFIG FILE ON THE HOST
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
#OTHER VERSIONS
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:alpine
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:stable
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:latest
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:mainline
#RUN ON DEBUG MODE
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx nginx-debug -g 'daemon off;'