nginx-noroot : Moved from Scriptbox

This commit is contained in:
unknown 2022-06-11 20:32:47 +07:00
parent eab150799a
commit d30de9686c
Signed by: minoplhy
GPG Key ID: 90667A59A9908AEC
6 changed files with 147 additions and 0 deletions

22
README.md Normal file
View File

@ -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
```

57
build.sh Normal file
View File

@ -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

41
configure.sh Normal file
View File

@ -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

1
script/reloadnginx.sh Normal file
View File

@ -0,0 +1 @@
~/nginx-settings/sbin/nginx -g 'daemon on; master_process on;' -s reload

2
script/startnginx.sh Normal file
View File

@ -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;'

24
script/stopnginx.sh Normal file
View File

@ -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