官方安装方法:http://openresty.org/en/installation.html
https://openresty.org/cn/installation.html
官方安装:
构建 OpenResty
下载
从下载页 Download下载最新的 OpenResty® 源码包,并且像下面的示例一样将其解压:
tar -xzvf openresty-VERSION.tar.gz
VERSION 的地方替换成您下载的源码包的版本号,比如说 0.8.54.6。
./configure
然后在进入 openresty-VERSION/ 目录, 然后输入以下命令配置:
./configure
默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录。
您可以指定各种选项,比如
./configure --prefix=/opt/openresty \ --with-luajit \ --without-http_redis2_module \ --with-http_iconv_module \ --with-http_postgres_module
试着使用 ./configure --help 查看更多的选项。
配置文件(./configure script)运行出错可以到 build/nginx-VERSION/objs/autoconf.err 找到。 VERSION 的地方必须与OpenResty版本号相对应, 比如 0.8.54.6。
Solaris的用户请注意:
对于 Solaris,安装开发库一般通过 OpenSSL 的形式插入 /lib, 因此当编译时出现 missing OpenSSL 说明您已经安装过了t, 特别是一些选项的时候 --with-ld-opt='-L/lib' 。
make
您可以使用下面的命令来编译:
make
如果您的电脑支持多核 make 工作的特性, 您可以这样编译:
make -j2
假设您是的机器是双核。
make install
如果前面的步骤都没有问题的话,您可以使用下面的命令安装l OpenResty到您的系统之中:
make install
在 Linux,通常包括 sudo来执行root权限做的事情。
阿里云安装方法:https://www.aliyun.com/jiaocheng/790120.html
1、创建安装目录:
makdir -p /usr/local/servers
2、安装依赖
yum install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perlreadline-devel pcre-devel openssl-devel gcc
3、下载最新的ngx_openresty
wget https://openresty.org/download/openresty-1.11.2.3.tar.gz
tar -zxvf openresty-1.11.2.3.tar.gz
4、安装LuaJIT
cd openresty-1.11.2.3/bundle/LuaJIT-2.1-20170405
make clean &;&; make &;&; make install
ln -sf LuaJIT-2.1-20170405 /usr/local/bin/luajit
5、下载ngx_cache_purge模块
该模块用于清理nginx缓存
cd /usr/src/openresty-1.11.2.3/bundle
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
6 、下载nginx_upstream_check_module模块
该模块用于ustream健康检查
cd /usr/src/openresty-1.11.2.3/bundle
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -zxvf v0.3.0.tar.gz
7 、安装 OpenResty
cd /usr/src/openresty-1.11.2.3
./configure --prefix=/usr/local/servers/openresty --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
make && make install
8、设置环境变量
vim /etc/profile
export ORPATH=/usr/local/servers/openresty
export PATH=$PATH:$ORPATH/bin:$ORPATH/nginx/sbin
source /etc/profile
就可以查看版本了:openresty -v
遇到错误
./configure: error: ngx_postgres addon was unable to detect version of the libpq library. ERROR: fai
解决办法:yum install postgresql-devel