1.安装依赖
yum install pcre-devel openssl-devel gcc curl
2.下载openresty(这里我的安装路径是/usr/local)
cd /usr/local
wget https://openresty.org/download/openresty-1.15.8.2.tar.gz
tar -zxvf openresty-1.15.8.2.tar.gz
cd openresty-1.15.8.2
2.安装LuaJIT
(openresty-xxx/bundle目录里存放着nginx核心和很多第三方模块,比如有我们需要的Lua和LuaJIT。)
cd bundle/LuaJIT-2.1-20190507/
make clean && make && make install
ln -sf luajit-2.1.0-alpha
3.下载ngx_cache_purge模块,该模块用于清理nginx缓存(这里我把他放入了openresty/bundle目录下)
cd ..
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
4.下载nginx_upstream_check_module模块,该模块用于ustream健康检查
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -xvf v0.3.0.tar.gz
5.安装openresty
cd ..
#./configure —help可以查看编译选项ls
#我的编译选项
./configure --prefix=/usr/local --user=root --group=root --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-http_realip_module --with-pcre --with-luajit --without-http-cache --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
也可以加上参数 --sbin-path=/usr/bin/nginx
安装:
make && make install
参数说明:
–with*** 安装一些内置/集成的模块
–with-http_realip_module 取用户真实ip模块
-with-pcre Perl兼容的达式模块
–with-luajit 集成luajit模块
–add-module 添加自定义的第三方模块,如此次的ngx_che_purge
6.到/usr/local目录下用ll命令查看,会发现多出来了如下目录,说明安装成功
7.为nginx添加软连接
sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx