[root@localhost openresty]# pwd
/home/openresty
[root@localhost openresty]# ll
总用量 56592
-rw-r--r-- 1 root root 38013850 4月 19 11:00 openresty-1.9.7.3.tar.gz
-rw-r--r-- 1 root root 13205180 4月 19 11:00 openresty_config.zip
-rwxr--r-- 1 root root 1683 4月 19 11:02 openresty-init.sh
-rw-r--r-- 1 root root 4429979 4月 19 11:00 openssl-1.0.1l.tar.gz
-rw-r--r-- 1 root root 1661535 4月 19 11:00 pcre-8.31.tar.gz
-rw-r--r-- 1 root root 54501 4月 19 11:00 telnet-0.17-47.el6.x86_64.zip
-rw-r--r-- 1 root root 571091 4月 19 11:00 zlib-1.2.8.tar.gz
通过openresty-init.sh安装各组件
#!/bin/bash
############################################################################
# @desc:
# - 1. create user;
# - 2. create default directories and authorize;
# - 3. @usage: sh openresty-init.sh
# @author: lzx
# @time: 2017-06-14
###########################################################################
#init dir
autoDir="/usr/local/src"
sourceDir="/home/openresty"
openrestyTarGz="openresty-1.9.7.3.tar.gz"
opensslTarGz="openssl-1.0.1l.tar.gz"
zlibTarGz="zlib-1.2.8.tar.gz"
pcreTarGz="pcre-8.31.tar.gz"
# create working dirs
mkdir -p /usr/local/src/{zlib,pcre,openssl,openresty}
#openresty 是否已经安装存在
cd /usr/local/
if [[ -d openresty ]]; then
echo "WARN: openresty is already installed, exit."
#return
exit
fi
#install Dependent package
#yum install -y gcc gcc-c++ pcre zlib openssl
#untar
cd ${sourceDir}
mv ${openrestyTarGz} openresty.tar.gz && tar zxvf openresty.tar.gz -C /usr/local/src/openresty --strip-component=1
mv ${opensslTarGz} openssl.tar.gz && tar zxvf openssl.tar.gz -C /usr/local/src/openssl --strip-component=1
mv ${zlibTarGz} zlib.tar.gz && tar zxvf zlib.tar.gz -C /usr/local/src/zlib --strip-component=1
mv ${pcreTarGz} pcre.tar.gz && tar zxvf pcre.tar.gz -C /usr/local/src/pcre --strip-component=1
chmod -R 777 ${autoDir}
#install openresty
cd ${autoDir}/openresty
./configure --with-http_stub_status_module --prefix=/usr/local/openresty --with-pcre=/usr/local/src/pcre --with-openssl=/usr/local/src/openssl --with-zlib=/usr/local/src/zlib
make && make install
if [[ $? == 0 ]]; then
echo "OK: openresty is installed, exit."
else
echo "ERROR: openresty is NOT installed, exit."
fi
上传文件并覆盖
[root@localhost openresty]# ll
总用量 0
drwxr-xr-x 2 root root 19 4月 19 11:08 bin
drwxr-xr-x 6 root root 56 4月 19 11:08 luajit
drwxr-xr-x 6 root root 70 4月 19 11:08 lualib
drwxr-xr-x 6 root root 54 4月 19 11:08 nginx
修改nginx.conf配置相应IP地址端口。
修改upstream.conf配置相应服务IP与端口。