1 #! /bin/bash
2
3 function openrestyinstall() {
4 cd /opt/openresty-1.11.2.3
5 ./configure --user=nginx --group=nginx --with-select_module --with-threads \
6 --with-http_realip_module --with-http_sub_module \
7 --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module \
8 --with-http_secure_link_module --with-http_perl_module --with-pcre \
9 --with-http_ssl_module --with-http_stub_status_module --with-http_auth_request_module \
10 --with-http_v2_module --with-openssl=/usr/local/openssl-1.0.2l > /dev/null
11 if [ $? -eq 0 ];then
12 gmake > /dev/null
13 if [ $? -ne 0 ];then
14 echo "gmake has some error" >> /opt/openresty.log
15 exit 1
16 fi
17 gmake install > /dev/null
18 if [ $? -ne 0 ];then
19 echo "gmake install has some error" >> /opt/openresty.log
20 exit 1
21 fi
22 else
23 echo "./configure has some error" >> /opt/openresty.log
24 exit 1
25 fi
26 }
27
28 function openrestyupdateconfig() {
29 mkdir /data/work/conf/conf.d -p
30 if [ $? -ne 0 ];then
31 echo "mkdir /data/work has some error" >> /opt/openresty.log
32 fi
33 mkdir /data/work/html
34 if [ $? -ne 0 ];then
35 echo "mkdir /data/work has some error" >> /opt/openresty.log
36 fi
37 mkdir /data/work/logs/{cpms,spms}/{access,error} -p
38 if [ $? -ne 0 ];then
39 echo "mkdir /data/work has some error" >> /opt/openresty.log
40 fi
41 cp /usr/local/openresty/nginx/conf/* /data/work/conf/
42 if id -u nginx > /dev/null 2>&1;then
43 echo "user nginx exist" >> /opt/openresty.log
44 else
45 useradd -M -s /sbin/nologin nginx
46 if [ $? -ne 0 ];then
47 echo "create user is error" >> /opt/openresty.log
48 fi
49 fi
50 }
51
52
53 yum install openssl-devel pcre-devel perl-devel perl-ExtUtils-Embed -y 2>&1 /dev/null
54
55 rm -rf /opt/openresty-1.11.2.3
56 rm -rf /opt/openssl-1.0.2l
57 rm -rf /usr/local/openresty
58 rm -rf /usr/local/openssl-1.0.2l
59
60 if [ -f "/opt/openresty-1.11.2.3.tar.gz" ];then
61 tar -xf /opt/openresty-1.11.2.3.tar.gz -C /opt
62 if [ $? -ne 0 ];then
63 echo "openresty tar error" >> /opt/openresty.log
64 fi
65 fi
66 if [ -f "/opt/openssl-1.0.2l.tar.gz" ];then
67 tar -xf /opt/openssl-1.0.2l.tar.gz -C /usr/local/
68 if [ $? -ne 0 ];then
69 echo "openssl tar error" >> /opt/openresty.log
70 fi
71 fi
72
73 openrestyinstall
74 if [ $? -ne 0 ];then
75 echo "openrestyinstall is some error"
76 exit 1
77 fi
78
79 openrestyupdateconfig
80 if [ $? -ne 0 ];then
81 echo "openrestyupdateconfig is some error" >> /opt/openresty.log
82 exit 1
83 fi