From d30de9686cb36ee5355ee1722587f51cf82bd857 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Jun 2022 20:32:47 +0700 Subject: [PATCH] nginx-noroot : Moved from Scriptbox --- README.md | 22 +++++++++++++++++ build.sh | 57 +++++++++++++++++++++++++++++++++++++++++++ configure.sh | 41 +++++++++++++++++++++++++++++++ script/reloadnginx.sh | 1 + script/startnginx.sh | 2 ++ script/stopnginx.sh | 24 ++++++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 README.md create mode 100644 build.sh create mode 100644 configure.sh create mode 100644 script/reloadnginx.sh create mode 100644 script/startnginx.sh create mode 100644 script/stopnginx.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d7814f --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# NGINX without Root +This is a mini project that I'll find any workaround for building NGINX without relies on Root Required Dependencies as much as possible + +# Setup Script + +### using Curl +``` +curl https://raw.githubusercontent.com/minoplhy/nginx-noroot/main/build.sh | bash +``` + +### using Wget +``` +wget https://raw.githubusercontent.com/minoplhy/nginx-noroot/main/build.sh | ./build.sh +``` + +# Root Required +I can't figure workaround for these dependencies + +``` +Openssl (unsuccessful build when using self compiled openssl) + - libssl-dev +``` \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..33d1cc9 --- /dev/null +++ b/build.sh @@ -0,0 +1,57 @@ +Build_directory=~/nginx_build +User_home=~ + +rm -rf ~/nginx_build +mkdir ~/nginx_build && cd ~/nginx_build + +# Get zlib +cd ~/nginx_build +if [[ -f "/usr/bin/curl" ]]; then + curl -L https://zlib.net/zlib-1.2.12.tar.gz --output zlib-1.2.12.tar.gz +elif [[ -f "/usr/bin/wget" ]]; then + wget https://zlib.net/zlib-1.2.12.tar.gz -O zlib-1.2.12.tar.gz +else + echo "Required Dependencies for download zlib doesn't exist" +fi +tar xzf zlib-1.2.12.tar.gz + +# Get pcre +cd ~/nginx_build +if [[ -f "/usr/bin/curl" ]]; then + curl -L https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz --output pcre-8.45.tar.gz +elif [[ -f "/usr/bin/wget" ]]; then + wget https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz -O pcre-8.45.tar.gz +else + echo "Required Dependencies for download pcre doesn't exist" +fi +tar xzf pcre-8.45.tar.gz + +# Build Nginx +cd ~/nginx_build +if [[ -f "/usr/bin/curl" ]]; then + curl -L https://nginx.org/download/nginx-1.21.6.tar.gz --output nginx-1.21.6.tar.gz +elif [[ -f "/usr/bin/wget" ]]; then + wget https://nginx.org/download/nginx-1.21.6.tar.gz -O nginx-1.21.6.tar.gz +else + echo "Required Dependencies for download Nginx doesn't exist" +fi + +tar xzf nginx-1.21.6.tar.gz && cd nginx-1.21.6 + +if [[ -f "/usr/bin/curl" ]]; then + curl https://raw.githubusercontent.com/minoplhy/nginx-noroot/main/configure.sh | bash +elif [[ -f "/usr/bin/wget" ]]; then + wget https://raw.githubusercontent.com/minoplhy/nginx-noroot/main/configure.sh | ./configure.sh +else + echo "Required Dependencies for download configure script doesn't exist" +fi + +make && make install + +## +## +## Additional Part. +## +## + +mkdir -p ~/nginx-settings/temp \ No newline at end of file diff --git a/configure.sh b/configure.sh new file mode 100644 index 0000000..864e132 --- /dev/null +++ b/configure.sh @@ -0,0 +1,41 @@ +Build_directory=~/nginx_build +User_home=~ + +./configure \ +--prefix=$User_home/nginx-settings \ +--pid-path=run/nginx.pid \ +--conf-path=nginx.conf \ +--http-log-path=logs/access.log \ +--error-log-path=logs/error.log \ +--modules-path=modules \ +--http-client-body-temp-path=$User_home/nginx-settings/temp/body \ +--http-fastcgi-temp-path=$User_home/nginx-settings/temp/fastcgi \ +--http-proxy-temp-path=$User_home/nginx-settings/temp/proxy \ +--http-scgi-temp-path=$User_home/nginx-settings/temp/scgi \ +--http-uwsgi-temp-path=$User_home/nginx-settings/temp/uwsgi \ +--with-compat \ +--with-debug \ +--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_gunzip_module \ +--with-http_gzip_static_module \ +--with-http_mp4_module \ +--with-http_random_index_module \ +--with-http_secure_link_module \ +--with-http_sub_module \ +--with-mail=dynamic \ +--with-mail_ssl_module \ +--with-stream \ +--with-stream_realip_module \ +--with-stream_ssl_module \ +--with-stream_ssl_preread_module \ +--with-pcre=$Build_directory/pcre-8.45 \ +--with-zlib=$Build_directory/zlib-1.2.12 \ No newline at end of file diff --git a/script/reloadnginx.sh b/script/reloadnginx.sh new file mode 100644 index 0000000..c93c17c --- /dev/null +++ b/script/reloadnginx.sh @@ -0,0 +1 @@ +~/nginx-settings/sbin/nginx -g 'daemon on; master_process on;' -s reload \ No newline at end of file diff --git a/script/startnginx.sh b/script/startnginx.sh new file mode 100644 index 0000000..4298501 --- /dev/null +++ b/script/startnginx.sh @@ -0,0 +1,2 @@ +~/nginx-settings/sbin/nginx -t -q -g 'daemon on; master_process on;' +~/nginx-settings/sbin/nginx -g 'daemon on; master_process on;' \ No newline at end of file diff --git a/script/stopnginx.sh b/script/stopnginx.sh new file mode 100644 index 0000000..30c637b --- /dev/null +++ b/script/stopnginx.sh @@ -0,0 +1,24 @@ +STOPDAEMON=`which start-stop-daemon` + +if [ "$STOPDAEMON" == "" ]; then + if [[ "$STARTSTOPLOCATE" != "" ]]; then + STOPDAEMON=$STARTSTOPLOCATE + elif [[ -f "/usr/sbin/start-stop-daemon" ]]; then + STOPDAEMON=/usr/sbin/start-stop-daemon + elif [[ -f "/usr/bin/start-stop-daemon" ]]; then + STOPDAEMON=/usr/bin/start-stop-daemon + elif [[ -f "/sbin/start-stop-daemon" ]]; then + STOPDAEMON=/sbin/start-stop-daemon + elif [[ -f "/usr/local/sbin/start-stop-daemon" ]]; then + STOPDAEMON=/usr/local/sbin/start-stop-daemon + elif [[ -f "/usr/local/bin/start-stop-daemon" ]]; then + STOPDAEMON=/usr/local/bin/start-stop-daemon + else + echo "Script Can't find the location of start-stop-daemon" + exit + fi +else + echo "" +fi + +$STOPDAEMON --quiet --stop --retry QUIT/5 --pidfile ~/nginx-settings/run/nginx.pid \ No newline at end of file