将Nginx和LibreSSL一起安装的shell脚本

#!/usr/bin/bash
WORK_DIR=/usr/local/src
NGINX_VER=1.16.1
LIBRESSL_VER=2.9.2

NGINX_USER=nginx
NGINX_GROUP=nginx

REBUILD_LIBRESSL=false
REBUILD_NGINX=false

usage_exit() {
        echo "Usage: $0 [-Aln]" 1>&2
        exit 1
}

while getopts Alnh OPT
do
        case $OPT in
                A) REBUILD_LIBRESSL=true
                   REBUILD_NGINX=true
                        ;;
                l) REBUILD_LIBRESSL=true
                        ;;
                n) REBUILD_NGINX=true
                        ;;
                h) usage_exit
                        ;;
                \?) usage_exit
                        ;;
        esac
done

if [ "${REBUILD_LIBRESSL}" != "true" -a "${REBUILD_NGINX}" != "true" ]; then
        usage_exit
fi

cd ${WORK_DIR}

wget -O libressl-${LIBRESSL_VER}.tar.gz http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VER}.tar.gz

rm -rf libressl-${LIBRESSL_VER}
tar xzf libressl-${LIBRESSL_VER}.tar.gz && cd libressl-${LIBRESSL_VER}

## LibreSSL
if [ "${REBUILD_LIBRESSL}" == "true" ]; then
        CFLAGS="-march=native -O2 -m64 -pipe -fomit-frame-pointer -mfpmath=sse -msse4 -msse4.1 -msse4.2" \
        CXXFLAGS="-march=native -O2 -m64 -pipe -fomit-frame-pointer -mfpmath=sse -msse4 -msse4.1 -msse4.2" \
        ./configure \
        --host=x86_64-redhat-linux-gnu \
        --build=x86_64-redhat-linux-gnu \
        --target=x86_64-redhat-linux \
        --program-prefix= \
        --prefix=/usr/local \
        --exec-prefix=/usr/local \
        --bindir=/usr/local/bin \
        --sbindir=/usr/local/sbin \
        --sysconfdir=/etc \
        --datadir=/usr/local/share \
        --includedir=/usr/local/include \
        --libdir=/usr/local/lib64 \
        --libexecdir=/usr/local/libexec \
        --localstatedir=/var \
        --sharedstatedir=/usr/com \
        --mandir=/usr/local/share/man \
        --infodir=/usr/local/share/info

        make -j2 check
        sudo make install
fi

## nginx
if [ "${REBUILD_NGINX}" == "true" ]; then
        cd ${WORK_DIR}

        wget -O nginx-${NGINX_VER}.tar.gz http://nginx.org/download/nginx-${NGINX_VER}.tar.gz

        rm -rf nginx-${NGINX_VER}
        tar xzf nginx-${NGINX_VER}.tar.gz && cd nginx-${NGINX_VER}

        CFLAGS="-march=native -O2 -m64 -pipe -fomit-frame-pointer -mfpmath=sse -msse4 -msse4.1 -msse4.2" \
        CXXFLAGS="-march=native -O2 -m64 -pipe -fomit-frame-pointer -mfpmath=sse -msse4 -msse4.1 -msse4.2" \
        ./configure \
        --prefix=/usr/local \
        --sbin-path=/usr/local/sbin/nginx \
        --conf-path=/etc/nginx/nginx.conf \
        --pid-path=/var/run/nginx.pid \
        --lock-path=/var/lock/nginx.lock \
        --error-log-path=/var/log/nginx/error_log \
        --http-log-path=/var/log/nginx/access_log \
        --user=${NGINX_USER} \
        --group=${NGINX_GROUP} \
        --with-file-aio \
        --with-ipv6 \
        --with-http_realip_module \
        --with-http_addition_module \
        --with-http_gzip_static_module \
        --with-http_stub_status_module \
        --with-http_v2_module \
        --with-http_ssl_module \
        --with-poll_module \
        --with-sha1-asm \
        --with-sha1=/usr/include \
        --http-client-body-temp-path=/tmp/nginx_client/ \
        --http-proxy-temp-path=/tmp/nginx_proxy/ \
        --http-fastcgi-temp-path=/tmp/nginx_fcgi/ \
        --without-mail_pop3_module \
        --without-mail_imap_module \
        --without-mail_smtp_module \
        --without-http_uwsgi_module \
        --without-http_scgi_module \
        --with-openssl=${WORK_DIR}/libressl-${LIBRESSL_VER}

        make -j2
        sudo make install
fi
广告
将在 10 秒后关闭
bannerAds