源码安装

#!/bin/bash
# 下载 解压 ./config make make instsll
# nginx source make install by taxue
# 2021-12-28 v1.0

nginx_url='https://nginx.org/download/nginx-1.20.2.tar.gz'
#nginx_bao=${nginx_url##*/}
nginx_bao=`basename $nginx_url`
bao_dir='/usr/local/src'

ping -c 1 -i.2 www.baidu.com
if [ $? -ne 0 ];then
        echo "网络不通,请检查网络!"
        exit 100
fi

yum -y install pcre-devel openssl openssl-devel
id nginx || useradd -r  -s /sbin/nologin -M nginx

[ -f ${bao_dir}/${nginx_bao} ] || wget $nginx_url -P $bao_dir/
cd $bao_dir
tar -xzvf $nginx_bao
cd `echo $nginx_url |awk -F'/' '{print $NF}' | awk -F'.tar' '{print $1}'`

./configure --prefix=/usr/local/nginx \
    --with-http_stub_status_module \
    --user=nginx --group=nginx \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --pid-path=/var/run/nginx.pid \
    --with-pcre \
    --with-http_ssl_module \
    --without-mail_pop3_module \
    --without-mail_imap_module \
    --with-http_gzip_static_module \
    --with-stream

make && make install

if [ $? -ne 0 ];then
        echo "编译失败,请检查"
        exit 100
fi

/usr/local/sbin/nginx -c /usr/local/nginx/conf/nginx.conf &
curl localhost

你可能感兴趣的:(源码安装)