Skip to content

Instantly share code, notes, and snippets.

@judge2020
Last active October 29, 2018 17:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judge2020/e3461e06c065830d1359adca1be90893 to your computer and use it in GitHub Desktop.
Save judge2020/e3461e06c065830d1359adca1be90893 to your computer and use it in GitHub Desktop.

To build nginx, run in terminal

wget https://gist.github.com/judge2020/e3461e06c065830d1359adca1be90893/raw/b77d7cd58606002b12392fc066fe1cdda5c0cd30/build_nginx.sh && source build_nginx.sh
mkdir -p ~/nginx
mkdir -p ~/nginx/_nginx
cd ~/nginx/_nginx
find . -maxdepth 1 -mindepth 1 -type d -exec echo mv "{}" "{}-$RANDOM" \;
cd ~/nginx
mv nginx-* _nginx
sudo apt install -y wget build-essential python3 python3-requests
sudo mkdir -p /var/lib/nginx/body
python3 -m pip install requests
cat << EOF > dlnginx.py
# Hopefilly this works for a while. As long as their CHANGES file doesnt change
from __future__ import print_function
import requests, os
f = requests.get('http://nginx.org/en/CHANGES')
a = f.text.split('Changes with nginx ')
i = 0
for ab in a:
i += 1
if i >= 3:
continue
if '1.' in ab:
version = ab[:7].strip(' ')
print(version)
file = 'nginx-' + version + '.tar.gz'
os.system('wget ' + r'http://nginx.org/download/' + file)
os.system('tar -xvf ' + file)
#r = requests.get(r'http://nginx.org/download/' + file, stream=True)
#with open(file, 'wb') as f:
# for chunk in r.iter_content():
# f.write(chunk)
EOF
python3 dlnginx.py
if [ ! -f pcre-8.40/NEWS ]; then
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && tar xzvf pcre-8.40.tar.gz
fi
zlib-1.2.11/FAQ
if [ ! -f zlib-1.2.11/FAQ ]; then
wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
fi
if [ ! -f openssl-1.1.0g/FAQ ]; then
wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz && tar xzvf openssl-1.1.0g.tar.gz
fi
git clone https://github.com/arut/nginx-rtmp-module
rm -rf *.tar.gz
cat << EOF > configure.sh
#!/bin/bash
cd nginx-1.*
./configure --prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www-data \
--group=www-data \
--build=Ubuntu \
--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-openssl=../openssl-1.1.0g \
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
--with-openssl-opt=no-nextprotoneg \
--with-openssl-opt=no-weak-ssl-ciphers \
--with-openssl-opt=no-ssl3 \
--with-pcre=../pcre-8.40 \
--with-pcre-jit \
--with-zlib=../zlib-1.2.11 \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_secure_link_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wno-error=date-time' \
--with-ld-opt='-Wno-error=date-time -Wl,-Bsymbolic-functions -Wl,-z,now' \
--add-module=../nginx-rtmp-module
EOF
sh configure.sh
cd nginx-*
[ -f /etc/systemd/system/nginx.service ] || sudo tee -a /etc/systemd/system/nginx.service << EOF
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
echo If everything went as planned, you should be able to "make" then "make Install".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment