目录
openresty安装在ubuntu下的安装
安装步骤:
# 创建目录/usr/servers,以后我们把所有软件安装在此目录
mkdir -p /usr/servers
cd /usr/servers/
# 安装依赖
apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl
# 下载ngx_openresty-1.7.7.2.tar.gz并解压
wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
tar -xzvf ngx_openresty-1.7.7.2.tar.gz
# 安装LuaJIT
cd /usr/servers/ngx_openresty-1.7.7.2/bundle/LuaJIT-2.1-20150120/
# 没有安装make的需要先安装
apt install make
apt install make-guile
# 没安装gcc的需要先执行以下命令
sudo apt-get build-dep gcc
make clean && make && make install
ln -sf luajit-2.1.0-alpha /usr/local/bin/luajit
# 下载ngx_cache_purge模块,该模块用于清理nginx缓存
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
# 下载nginx_upstream_check_module模块,该模块用于ustream健康检查
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -xvf v0.3.0.tar.gz
# 安装ngx_openresty
cd /usr/servers/ngx_openresty-1.7.7.2
./configure --prefix=/usr/servers --with-http_realip_module --with-pcre --with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
# 报错 checking for zlib library ... not found,需要安装 zlib
sudo apt-get install zlib1g-dev
make && make install
# 报错 recipe for target 'objs/src/event/ngx_event_openssl.o' failed,openssl版本问题,需要安装旧版本
# 需要指定旧版本,推荐在编译 Nginx 时指定 OpenSSL 源码目录,而不是使用系统自带的版本,这样更可控
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget -O openssl.tar.gz -c https://github.com/openssl/openssl/archive/OpenSSL_1_0_2k.tar.gz
tar zxf openssl.tar.gz
mv openssl-OpenSSL_1_0_2k/ openssl
# 重新配置 ngx_openresty
cd /usr/servers/ngx_openresty-1.7.7.2
./configure
--prefix=/usr/servers
--with-http_realip_module
--with-pcre
--with-luajit
--add-module=./bundle/ngx_cache_purge-2.3/
--add-module=./bundle/nginx_upstream_check_module-0.3.0/
--with-openssl=./bundle/openssl
-j2
# 重新make
make && make install
# 启动nginx,访问 http://localhost/ 成功即可
/usr/servers/nginx/sbin/nginx
拓展: