二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

    • 关于nginx请求头中有下划线_的坑
    • 利用nginx+sftp实现一个可供用户下载的服务
    • nginx配置文件及模块
    • 通过脚本按天切割nginx的日志
    • nginx通过四层代理实现端口转发
    • NGINX基于cookie针对同一域名进行分流转发
    • nginx利用内置模块配置限速限流
    • 利用NGINX内置模块mirror进行流量复制等操作
    • 使用$remote_user字段记录访问NGINX的用户
    • 从NGINX自身配置文件中定义访问日志按时间切割
    • NGINX配置单独代理百度的sitemap文件
    • nginx配置微信小程序校验及其他
    • nginx配置gzip压缩
    • 由Nginx集中代理分散的PHP集群的实践
    • http状态码详解
    • OpenResty-1-13-6-2-新增ldap模块儿
    • 排查NGINX的open_file_cache导致发布后访问404的问题
    • 制作OpenResty-1-19-9-1的RPM包
      • 1,物料
      • 2,我的
      • 3,打包
      • 4,模块儿
    • 从Nginx过滤打印user-agent为clb-healthcheck的日志聊聊Nginx的日志自定义打印
  • Php

  • Zabbix

  • AWS

  • Prometheus

  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Nginx
二丫讲梵
2021-10-21
目录

制作OpenResty-1-19-9-1的RPM包

文章发布较早,内容可能过时,阅读注意甄别。

源码包有源码包的灵活,RPM 包有 RPM 包的方便,一些比较常用的生产工具包,打成 RPM 包还是比较方便的。

# 1,物料

  • openresty 官网 (opens new window)
  • openresty-packaging (opens new window):官方维护的 RPM 构建的基础文件。

# 2,我的

官方提供的包大多给的是默认配置,不大适合在生产直接使用,因此借鉴官方的包进行了一些简单的调整改造,并将基础文件整理成了项目:

rpmbuild

工作中常用的RPM构建spec

- name: rpmbuild
  desc: 工作中常用的RPM构建spec
  avatar: https://avatars2.githubusercontent.com/u/416130?s=460&u=8753e86600e300a9811cdc539aa158deec2e2724&v=4 # 可选
  link: https://github.com/eryajf/rpmbuild # 可选
  bgColor: "#0074ff" # 可选,默认var(--bodyBg)。颜色值有#号时请添加单引号
  textColor: "#fff" # 可选,默认var(--textColor)
1
2
3
4
5
6

调整说明如下:

  • 替换了默认的 nginx.conf 文件内容

    • 调整日志格式为 json,日志路径如下

      error_log /data/log/error.log;
      access_log /data/log/tmp.log json;
      
      1
      2
    • 调整支持传递带有下划线的 header。

  • 主动创建一些软链,便于维护或者规范

    ln -snf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
    ln -snf /usr/local/openresty/nginx/conf /etc/nginx
    
    1
    2
  • 添加基于 logrotate 的日志清理策略

    /data/log/tmp.log
    /data/log/error.log
    {
        daily
        dateext
        missingok
        rotate 7
        notifempty
        create 755 www
        sharedscripts
        postrotate
            [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
        endscript
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

添加模块儿如下:

  • 添加 ldap 模块儿的支持
  • 添加 upsync 模块儿的支持

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

Copyright 二丫讲梵 (opens new window) 版权所有

# 3,打包

如下内容基于 CentOS7 进行。

首先将项目克隆在主机的 root 目录下,因为 rpmbuild 有不少变量是基于家目录来做的。

$ git clone https://github.com/eryajf/rpmbuild.git
1

配置阿里和 openresty 的 yum 源:

$ yum -y install yum-utils
$ yum-config-manager --add-repo http://mirrors.aliyun.com/repo/Centos-7.repo
$ yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
1
2
3

安装基础构建工具:

$ yum -y install rpm-build redhat-rpm-config rpmdevtools
1

安装项目编译依赖:

$ yum -y install gcc gcc-c++ systemtap-sdt-devel openresty-zlib-devel openresty-openssl-devel openresty-pcre-devel gd-devel openresty-openssl111-devel ccache
1

下载 spec 中定义的源码文件:

# 进入到工作目录
$ cd /root/rpmbuild/SPECS/openresty/
$ spectool -g -R openresty.spec
1
2
3

执行打包命令:

$ rpmbuild -ba openresty.spec
1

当看到最后结果返回值为 0 时,则说明构建成功。如果有报错,则根据报错信息进行具体应对工作。

成功之后,会在 /root/rpmbuild/RPMS 目录中生成构建好的 rpm 包。

查看构建的包信息:

$ cd /root/rpmbuild/RPMS/x86_64
$ rpm -qpi openresty-1.19.9.1-1.eryajf.el7.x86_64.rpm
Name        : openresty
Version     : 1.19.9.1
Release     : 1.eryajf.el7
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 3714763
License     : BSD
Signature   : (none)
Source RPM  : openresty-1.19.9.1-1.eryajf.el7.src.rpm
Build Date  : Thu Oct 21 23:00:12 2021
Build Host  : 13264c814536
Relocations : (not relocatable)
Packager    : https://github.com/eryajf
URL         : https://openresty.org/
Summary     : OpenResty, scalable web platform by extending NGINX with Lua
Description :
This package contains the core server for OpenResty. Built for production
uses.

OpenResty is a full-fledged web platform by integrating the standard Nginx
core, LuaJIT, many carefully written Lua libraries, lots of high quality
3rd-party Nginx modules, and most of their external dependencies. It is
designed to help developers easily build scalable web applications, web
services, and dynamic web gateways.

By taking advantage of various well-designed Nginx modules (most of which
are developed by the OpenResty team themselves), OpenResty effectively
turns the nginx server into a powerful web app server, in which the web
developers can use the Lua programming language to script various existing
nginx C modules and Lua modules and construct extremely high-performance
web applications that are capable to handle 10K ~ 1000K+ connections in
a single box.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

# 4,模块儿

日常工作中可能会有其他模块儿的使用场景,一般通过 --add-module进行添加,我这里目前添加了两个模块儿:

$ ll
total 104
-rw-r--r--  1 liqilong  staff    12K 10 21 14:59 openresty-ldap.spec
-rw-r--r--  1 liqilong  staff    12K 10 21 14:58 openresty-upsync.spec
1
2
3
4

一个是支持基于 ldap 做认证的 ldap 模块儿。配置参考:点我 (opens new window)

一个是微博开源的能够基于 consul 做配置中心的 upsync 模块儿。

如果你在使用过程中有什么问题,欢迎留言交流。

微信 支付宝
#nginx#openresty#rpm#consul#ldap
上次更新: 2024/06/13, 22:13:45
排查NGINX的open_file_cache导致发布后访问404的问题
从Nginx过滤打印user-agent为clb-healthcheck的日志聊聊Nginx的日志自定义打印

← 排查NGINX的open_file_cache导致发布后访问404的问题 从Nginx过滤打印user-agent为clb-healthcheck的日志聊聊Nginx的日志自定义打印→

最近更新
01
学习周刊-总第213期-2025年第22周
05-29
02
学习周刊-总第212期-2025年第21周
05-22
03
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式