CentOS7.x 基于源码构建安装openresty

参考:

https://openresty.org/en/installation.html
https://openresty.org/en/installation.html#building-openresty


1.前期依赖库安装:

yum install -y make cmake gcc curl 
yum install -y prel pcre-devel
yum install -y openssl openssl-devel

# mkdir -p /opt/software/openresty

2.下载:
# wget https://openresty.org/download/openresty-1.17.8.2.tar.gz

3.解压:
# tar -zxvf openresty-1.17.8.2.tar.gz -C /opt/software/openresty/

# cd /opt/software/openresty/openresty-1.17.8.2/

4.编译:
# ./configure --prefix=/usr/local/openresty

默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录。
(<openresty-prefix> is default to /usr/local/openresty/ unless being overridden by ./configure's --prefix=PATH option).

编译成功提示:

Type the following commands to build and install:
    gmake
    gmake install
    
    
也可以携带模块参数等安装,如:

# ./configure --prefix=/usr/local/openresty --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module

5.安装:
# make   -- 还可以根据CPU核数添加 j参数,比如两核:j2
# sudo make install


sed -e "s|%%PREFIX%%|/usr/local/openresty/nginx|" \


环境变量

export PATH=/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:$PATH

官方建议:
# better also add the following line to your ~/.bashrc or ~/.bash_profile file.
export PATH=/usr/local/openresty/bin:$PATH

6.配置:

cd /usr/local/openresty/nginx/conf
vim nginx.conf 

或者直接:vim /usr/local/openresty/nginx/conf/nginx.conf

开放root权限,在文件顶部添加:user root root;

查看版本:
# /usr/local/openresty/bin/openresty -V
nginx version: openresty/1.17.8.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

7.启动:

# /usr/local/openresty/bin/openresty

查看启动进程:ps aux |grep openresty


8.访问:

# curl 127.0.0.1

显示:Welcome to OpenResty!
安装成功!

Welcome to OpenResty!
If you see this page, the OpenResty web platform is successfully installed and working. Further configuration is required.


 

### OpenResty 源码编译安装教程 #### 一、概述 OpenResty 是一个基于 Nginx 的 Web 平台,集成了多种第三方模块以及大部分常用的 Lua 库,旨在提供更强大的处理能力[^1]。 #### 二、准备阶段 为了成功编译并安装 OpenResty,需要先安装一些必要的开发库和工具。对于不同的操作系统,所需的包管理器命令有所不同: - 对于 CentOS 或其他 RedHat 系列发行版: ```bash yum install pcre-devel openssl-devel gcc curl zlib-devel ``` - 对于 Debian/Ubuntu 发行版,则应执行如下命令来获取所需依赖项: ```bash apt-get update && apt-get install libpcre3-dev \ libssl-dev perl make build-essential curl ``` 以上操作确保了系统具备构建 OpenResty 所需的基础环境[^3][^4]。 #### 三、下载源代码 前往 [OpenResty 官方网站](https://openresty.org/en/download.html),找到最新稳定版本的 tarball 文件链接,并通过 `wget` 命令将其下载到本地机器上。也可以直接使用 wget 下载指定版本: ```bash wget https://openresty.org/download/openresty-1.21.4.1.tar.gz tar -1.21.4.1/ ``` 这里假设选择了特定版本号作为例子;实际应用时应当替换为最新的可用版本。 #### 四、配置与编译过程 进入解压后的文件夹后,运行 configure 脚本来设定编译参数。可以根据需求调整选项列表中的各项设置,比如启用或禁用某些功能模块等。默认情况下会自动检测系统的最优配置方案: ```bash ./configure --prefix=/usr/local/openresty make sudo make install ``` 上述指令指定了将程序安装至 `/usr/local/openresty` 目录下。如果希望更改此路径或其他高级选项,请查阅官方文档了解更多细节。 #### 五、验证安装成果 完成所有步骤之后,可以通过以下方式检验是否正确部署了 OpenResty: ```bash /usr/local/openresty/nginx/sbin/nginx -v ``` 这将会显示已安装成功的 Nginx 版本信息,证明整个流程顺利完成。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值