一、Openresty的环境安装,


下载地址

http://www.lua.org/ftp/#source
http://openresty.org/cn/download.html

安装lua

下载完解压cd到目录下执行:

wget http://www.lua.org/ftp/lua-5.2.4.tar.gz
tar -xvf lua-5.2.4.tar.gz
cd lua-5.2.4
make macosx
sudo make install

查看下版本号:

>lua -v
>Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio

源代码编译安装

主要是源代码安装:
首先下载最新的版本例如openresty-1.11.2.5.tar.gz

然后要下载其他依赖的包:

  • pcre:
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

  • zlib:
    https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz

  • openssl:
    https://www.openssl.org/source/openssl-1.0.2o.tar.gz

把这些包都放在一个文件夹下,解压。
然后cd到openresty-1.11.2.5目录下执行以下命令

./configure --prefix=/user/local/Cellar/openresty/1.11.2.5 \
--with-luajit \
--with-http_realip_module \
--with-pcre-jit \
--with-ipv6 \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-openssl=../openssl-1.0.2o --with-pcre=../pcre-8.40 -j4 --with-zlib=../zlib-1.2.11

--prefix=[根据自己要装的位置修改,上文是我的mac的安装位置]
这个是比较完整的安装,那些--with-http是可以先不加的。
如果没有报错,然后执行(可能需要sudo)

make
make install

macos brew安装

brew tap openresty/brew
brew install openresty

如果你之前是从 homebrew/nginx 安装的 OpenResty,请先执行:

brew untap homebrew/nginx

如果没有安装brew环境,那么需要执行下面命令

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

ruby就自行安装了

centos yum安装

你可以在你的 CentOS 系统中添加 openresty 仓库,这样就可以便于未来安装或更新我们的软件包(通过 yum update 命令)。运行下面的命令就可以添加我们的仓库:

sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

然后就可以像下面这样安装软件包,比如 openresty:

sudo yum install openresty

如果你想安装命令行工具 resty,那么可以像下面这样安装 openresty-resty 包:

sudo yum install openresty-resty

命令行工具 opm 在 openresty-opm 包里,而 restydoc 工具在 openresty-doc 包里头。

列出所有 openresty 仓库里头的软件包:

sudo yum --disablerepo="*" --enablerepo="openresty" list available

查看环境

>openresty -v
>nginx version: openresty/1.11.2.5

相关内容

    暂无相关文章