Created
February 22, 2022 09:56
-
-
Save kerus1024/9759854e0e04431a3a7d238cfd36ae4d to your computer and use it in GitHub Desktop.
Build OpenResty Nginx from Sourcecode on Debian 11 with brotil supported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Build OpenResty Nginx from Sourcecode on Debian 11/10 (support brotil) | |
# | |
set -x | |
set -e | |
ENV_OPENSSLVER=1.1.1m | |
ENV_OPENRESTYVER=1.19.9.1 | |
apt update -y | |
apt install -y build-essential git wget | |
# | |
# OpenSSL | |
# | |
apt install -y zlib1g-dev | |
mkdir -p /opt/openssl | |
wget -qO- https://www.openssl.org/source/openssl-$ENV_OPENSSLVER.tar.gz | tar xvz --strip 1 -C /opt/openssl | |
cd /opt/openssl | |
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib | |
make -j$(nproc) && make install | |
cat > /etc/ld.so.conf.d/openssl.conf <<< "/usr/local/ssl/lib" && \ | |
ldconfig -v | |
ln -sf /usr/local/ssl/bin/openssl /usr/bin/openssl | |
cat > /etc/profile.d/openssl.sh << _EOF | |
export OPENSSL_PATH="/usr/local/ssl/bin" | |
export OPENSSL_ROOT_DIR="/usr/local/ssl" | |
export OPENSSL_LIBRARIES="/usr/local/ssl/lib" | |
export OPENSSL_INCLUDE_DIR="/usr/local/ssl/include" | |
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | |
export SSL_CERT_DIR=/etc/ssl/certs | |
PATH=$PATH:$OPENSSL_PATH | |
_EOF | |
chmod 755 /etc/profile.d/openssl.sh | |
# | |
# PCRE Library | |
# | |
apt install -y libreadline-dev | |
git clone git://sourceware.org/git/bzip2.git /opt/bzip2 | |
cd /opt/bzip2 | |
make -j$(nproc) && make install | |
mkdir -p /opt/pcre | |
wget -qO- https://jaist.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz | tar xvz --strip 1 -C /opt/pcre | |
cd /opt/pcre | |
./configure --prefix=/usr \ | |
--docdir=/usr/share/doc/pcre-8.42 \ | |
--enable-unicode-properties \ | |
--enable-pcre16 \ | |
--enable-pcre32 \ | |
--enable-pcregrep-libz \ | |
--enable-pcregrep-libbz2 \ | |
--enable-pcretest-libreadline \ | |
--disable-static | |
make -j$(nproc) && \ | |
make install | |
# | |
# OpenResty | |
# | |
apt install -y libgeoip-dev | |
mkdir -p /opt/openresty | |
wget -qO- https://openresty.org/download/openresty-$ENV_OPENRESTYVER.tar.gz | tar xvz --strip 1 -C /opt/openresty | |
cd /opt/openresty | |
git clone --recursive https://github.com/google/ngx_brotli /opt/openresty/ngx_brotli | |
./configure --prefix=/usr/local/openresty \ | |
--with-cc-opt="-I /usr/local/ssl/include" \ | |
--with-ld-opt="-L /usr/local/ssl/lib" \ | |
--with-compat \ | |
--add-module=./ngx_brotli \ | |
--with-pcre-jit \ | |
--with-http_realip_module \ | |
--with-http_geoip_module=dynamic \ | |
--with-http_v2_module \ | |
--with-http_gzip_static_module \ | |
--with-http_slice_module \ | |
--with-stream \ | |
--with-stream_ssl_module | |
make -j$(nproc) && make install | |
cat > /lib/systemd/system/openresty.service << _EOF | |
[Unit] | |
Description=Openresty Nginx HTTP Server | |
After=syslog.target network-online.target remote-fs.target nss-lookup.target | |
Wants=network-online.target | |
[Service] | |
Type=forking | |
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid | |
ExecStartPre=/usr/sbin/nginx -t | |
ExecStart=/usr/sbin/nginx | |
ExecReload=/usr/sbin/nginx -s reload | |
ExecStop=/bin/kill -s QUIT $MAINPID | |
PrivateTmp=true | |
[Install] | |
WantedBy=multi-user.target | |
_EOF | |
chmod 755 /lib/systemd/system/openresty.service | |
systemctl daemon-reload | |
ln -s /usr/local/openresty/bin/openresty /usr/sbin/nginx | |
ln -s /lib/systemd/system/openresty.service /lib/systemd/system/nginx.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment