Skip to content

Instantly share code, notes, and snippets.

@blanklin030
Last active October 30, 2018 04:15
Show Gist options
  • Save blanklin030/1f7aa2bb938f6ed579aa8d42d6366c0e to your computer and use it in GitHub Desktop.
Save blanklin030/1f7aa2bb938f6ed579aa8d42d6366c0e to your computer and use it in GitHub Desktop.
自动安装nginx
#nginx的gzip模块需要zlib库,rewrite模块需要pcre库,ssl模块需要openssl库,查看程序是否已安装:
rpm -q pcre
rpm -q openssl
rpm -q zlib
rpm -q nginx
#!/usr/bin/env bash
#创建用户和组
echo "======创建用户和组======"
/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www
if [ ! -d /tmp/nginx ];then
mkdir /tmp/nginx
fi
cd /tmp/nginx
#安装PCRE库
echo "======安装PCRE库======"
if [ ! -d pcre-8.35 ];then
wget https://nchc.dl.sourceforge.net/project/pcre/pcre2/10.32/pcre2-10.32.tar.bz2
tar -zxvf pcre2-10.32.tar.bz2
fi
cd pcre2-10.32
./configure
make && make install
#安装zlib库
echo "======安装zlib库======"
if [ ! -d zlib-1.2.8 ];then
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
sleep 3
fi
cd zlib-1.2.8
./configure
make && make install
#安装ssl
echo "======安装ssl======"
if [ ! -d openssl-1.0.1g ];then
wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
tar -zxvf openssl-1.0.1g.tar.gz
sleep 3
fi
cd openssl-1.0.1g
./configure
make && make install
rm -fr openssl-1.0.1g.tar.gz
#安装nginx
echo "======安装nginx======"
if [ ! -d nginx-1.7.0 ];then
wget http://nginx.org/download/nginx-1.7.0.tar.gz
tar zxvf nginx-1.7.0.tar.gz
sleep 3
fi
cd nginx-1.7.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
make && make install
rm -fr /tmp/nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment