#! /bin/bash
function openrestyinstall() {
cd /opt/openresty-1.11.2.3
./configure --user=nginx --group=nginx --with-select_module --with-threads \
--with-http_realip_module --with-http_sub_module \
--with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module \
--with-http_secure_link_module --with-http_perl_module --with-pcre \
--with-http_ssl_module --with-http_stub_status_module --with-http_auth_request_module \
--with-http_v2_module --with-openssl=/usr/local/openssl-1.0.2l > /dev/null
if [ $? -eq ];then
gmake > /dev/null
if [ $? -ne ];then
echo "gmake has some error" >> /opt/openresty.log
exit
fi
gmake install > /dev/null
if [ $? -ne ];then
echo "gmake install has some error" >> /opt/openresty.log
exit
fi
else
echo "./configure has some error" >> /opt/openresty.log
exit
fi
}
function openrestyupdateconfig() {
mkdir /data/work/conf/conf.d -p
if [ $? -ne ];then
echo "mkdir /data/work has some error" >> /opt/openresty.log
fi
mkdir /data/work/html
if [ $? -ne ];then
echo "mkdir /data/work has some error" >> /opt/openresty.log
fi
mkdir /data/work/logs/{cpms,spms}/{access,error} -p
if [ $? -ne ];then
echo "mkdir /data/work has some error" >> /opt/openresty.log
fi
cp /usr/local/openresty/nginx/conf/* /data/work/conf/
if id -u nginx > /dev/null 2>&1;then
echo "user nginx exist" >> /opt/openresty.log
else
useradd -M -s /sbin/nologin nginx
if [ $? -ne 0 ];then
echo "create user is error" >> /opt/openresty.log
fi
fi
}
yum install openssl-devel pcre-devel perl-devel perl-ExtUtils-Embed -y 2>&1 /dev/null
rm -rf /opt/openresty-1.11.2.3
rm -rf /opt/openssl-1.0.2l
rm -rf /usr/local/openresty
rm -rf /usr/local/openssl-1.0.2l
if [ -f "/opt/openresty-1.11.2.3.tar.gz" ];then
tar -xf /opt/openresty-1.11.2.3.tar.gz -C /opt
if [ $? -ne 0 ];then
echo "openresty tar error" >> /opt/openresty.log
fi
fi
if [ -f "/opt/openssl-1.0.2l.tar.gz" ];then
tar -xf /opt/openssl-1.0.2l.tar.gz -C /usr/local/
if [ $? -ne 0 ];then
echo "openssl tar error" >> /opt/openresty.log
fi
fi
openrestyinstall
if [ $? -ne 0 ];then
echo "openrestyinstall is some error"
exit 1
fi
openrestyupdateconfig
if [ $? -ne 0 ];then
echo "openrestyupdateconfig is some error" >> /opt/openresty.log
exit 1
fi