1.环境前提
OpenResty是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项,所以先安装nginx
https://blog.csdn.net/SHI940637335/article/details/130183027
nginx -v
2.安装编译环境
OpenResty插件分为自带插件以及第三方插件,如果是自带插件直接激活就可以,如果是第三方插件需要手动下载插件添加进去,这里我们以本地缓存插件安装举例
yum install -y make cmake gcc gcc-c++ autoconf automake libpng-devel libjpegdevel zlib libxml2-devel ncurses-devel bison libtool-ltdl-devel libiconv libmcrypt mhash mcrypt pcre-devel openssl-devel freetype-devel libcurl-devel luadevel readline-devel curl wget
3.下载源码
mkdir /usr/local/openresty
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
tar -zxvf openresty-1.21.4.1.tar.gz
4.下载缓存插件
mkdir /usr/local/openresty/modules&& cd /usr/local/openresty/modules
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar -zxvf ngx_cache_purge-2.3.tar.gz
5.编译OpenResty
选择需要的插件启用, –with-Components 激活组件,–without 则是禁止组件 ,–add-module是安装第三方模块
./configure --prefix=/usr/local/openresty --with-luajit --without-http_redis2_module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --add-module=/usr/local/openresty/modules/ngx_cache_purge-2.3
这里禁用了 redis组件 并且 安装了第三方缓存组件出现如下界面表示编译成功
6.安装OpenResty
gmake && gmake install
7.环境设置
vim /etc/profile
export PATH=$PATH:/usr/local/openresty/nginx/sbin
source /etc/profile