Skip to content

Instantly share code, notes, and snippets.

@alex-79
Last active June 7, 2024 06:21
Show Gist options
  • Save alex-79/d0cfa148728c761e83ac5c4f052c7fb2 to your computer and use it in GitHub Desktop.
Save alex-79/d0cfa148728c761e83ac5c4f052c7fb2 to your computer and use it in GitHub Desktop.
openresty-openssl-brotli-install
#!/bin/bash
apt-get install build-essential ca-certificates zlib1g-dev libpcre3 libpcre3-dev tar unzip libssl-dev checkinstall git uuid-dev libgeoip-dev perl make curl cmake
OPENSSL_VER=3.3.1
OPENRESTY_VER=1.25.3.1
cd /opt
wget -c https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz
tar -xzvf openssl-$OPENSSL_VER.tar.gz
rm openssl-$OPENSSL_VER.tar.gz
cd /opt
git clone --recurse-submodules -j `nproc` https://github.com/google/ngx_brotli
cd ngx_brotli/deps/brotli
mkdir out && cd out
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..
cmake --build . --config Release --target brotlienc
cd ../../../..
cd /opt
wget -qO- https://openresty.org/download/openresty-$OPENRESTY_VER.tar.gz | tar zxf -
cd openresty-$OPENRESTY_VER
./configure \
--prefix=/usr/local/openresty \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/openresty.pid \
--lock-path=/var/run/openresty.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--user=www-data \
--group=www-data \
--without-http_ssi_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_split_clients_module \
--without-http_memcached_module \
--without-http_empty_gif_module \
--without-http_browser_module \
--with-http_geoip_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-ipv6 \
--with-http_mp4_module \
--with-http_auth_request_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-openssl=/opt/openssl-$OPENSSL_VER \
--add-module=/opt/ngx_brotli
make -j `nproc`
#make install
checkinstall --pkgname=openresty --pkgversion=$OPENRESTY_VER --nodoc --install=no
dpkg -i /opt/openresty-$OPENRESTY_VER/openresty_$OPENRESTY_VER*.deb
cat > /lib/systemd/system/openresty.service << EOF
[Unit]
Description=A dynamic web platform based on Nginx and LuaJIT.
After=network.target
[Service]
Type=forking
PIDFile=/var/run/openresty.pid
ExecStartPre=/usr/local/openresty/bin/openresty -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/openresty/bin/openresty -g 'daemon on; master_process on;'
ExecReload=/usr/local/openresty/bin/openresty -g 'daemon on; master_process on;' -s reload
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
mkdir -p /var/cache/nginx
mkdir -p /var/log/nginx
export PATH=/usr/local/openresty/bin:$PATH
systemctl enable openresty.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment