镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

本文将介绍如何在 Ubuntu 上使用源码安装 OpenResty。

目标

  • Ubuntu 18.04
  • OpenResty 1.19.3.2

安装依赖

zlib1g-dev: the HTTP gzip module requires the zlib library.

apt-get update -y
apt-get install -y libpcre3-dev \
libssl-dev \
perl \
make \
build-essential \
curl \
zlib1g-dev</pre>

下载 OpenResty

cd /opt
curl -LO https://openresty.org/download/openresty-1.19.3.2.tar.gz
tar zxf openresty-1.19.3.2.tar.gz</pre>

安装 OpenResty

.configure \
--with-http_gzip_static_module \
--with-http_v2_module \
--with-http_stub_status_module make
make install</pre>

使用 systemd 管理 OpenResty 服务

编写 Service 文件

在 /usr/lib/systemd/system 目录下创建一个 openresty.service 文件,文件内容如下:

# Stop dance for OpenResty
# =========================
#
# ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=The OpenResty Application Platform
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target [Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /usr/local/openresty/nginx/logs/nginx.pid
TimeoutStopSec=5
KillMode=mixed [Install]
WantedBy=multi-user.target</pre>

启动 OpenResty

# 设置自启动
systemctl enable openresty # 启动 OpenResty
systemctl start openresty # 查看 OpenResty 服务状态
systemctl status openresty
● openresty.service - The OpenResty Application Platform
Loaded: loaded (/usr/lib/systemd/system/openresty.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-07-10 11:36:07 CST; 26min ago
Process: 12735 ExecStart=/usr/local/openresty/nginx/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 12734 ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 12736 (nginx)
Tasks: 2 (limit: 1126)
CGroup: /system.slice/openresty.service
├─12736 nginx: master process /usr/local/openresty/nginx/sbin/nginx -g daemon on; master_process on;
└─12737 nginx: worker process Jul 10 11:36:07 iZj6c0qglm7rjjctj7zxnfZ systemd[1]: Starting The OpenResty Application Platform...
Jul 10 11:36:07 iZj6c0qglm7rjjctj7zxnfZ systemd[1]: openresty.service: Failed to parse PID from file /usr/local/openresty/nginx/logs/nginx.pid:
Jul 10 11:36:07 iZj6c0qglm7rjjctj7zxnfZ systemd[1]: Started The OpenResty Application Platform.</pre>

一键安装脚本

GitHub Gist

本文转自:https://segmentfault.com/a/1190000040325948

在 Ubuntu 上使用源码安装 OpenResty的更多相关文章

  1. ubuntu php5.6源码安装

    本系列的lnmp的大框架基本上是按照http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan ...

  2. 使用Notepad++远程编辑Ubuntu上的源码

    简单搭建了在Windows上远程编辑Ubuntu Server 14.04上面源代码的环境,记录一下,给需要的人. Notepad++安装NppFTP 从插件菜单打开PluginManager,选中N ...

  3. [笔记] Ubuntu 18.04源码安装caffe流程

    虽然Ubuntu 18.04可以通过apt安装caffe,但是为了使用最新的代码,还是值得从源码安装一遍的. 安装环境 OS: Ubuntu 18.04 64 bit 显卡: NVidia GTX 1 ...

  4. ubuntu mysql5.7源码安装

    本系列的lnmp的大框架基本上是按照http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan ...

  5. 在CentOS7上源码安装OpenResty

    您必须将这些库perl 5.6.1+libreadlinelibpcrelibssl安装在您的电脑之中. 对于 Linux来说, 您需要确认使用 ldconfig 命令,让其在您的系统环境路径中能找到 ...

  6. ubuntu上用源码进行一键安装mysql

      首先卸载原有的mysql: 首先查看自己的mysql有哪些依赖 #dpkg --list|grep mysql 先卸载 #sudo apt-get remove mysql-common #sud ...

  7. 简单说说Ubuntu利用bzr源码安装OpenERP7.0的操作步骤

    1.修改Ubuntu国内更新源,具体方法自己baidu.google. 修改更新源后,更新系统 sudo apt-get update sudo apt-get upgrade 复制代码 2.安装Po ...

  8. centos 7 源码安装openresty

    Openresty 官网 http://openresty.org Openresty源码下载页面 http://openresty.org/en/download.html Openresty 简易 ...

  9. ubuntu vim8.0源码安装

    安装篇 从https://github.com/vim/vim下载相应zip源码文件,利用unzip vim-master.zip 命令解压到当前用户目录,即~: 解压后进入vim的src目录,首先, ...

随机推荐

  1. 03并发编程(多道技术+进程理论+进程join方法)

    目录 03 并发编程 03 并发编程

  2. C# 实例解释面向对象编程中的开闭原则

    在面向对象编程中,SOLID 是五个设计原则的首字母缩写,旨在使软件设计更易于理解.灵活和可维护.这些原则是由美国软件工程师和讲师罗伯特·C·马丁(Robert Cecil Martin)提出的许多原 ...

  3. iNeuOS工业互联网操作系统,顺利从NetCore3.1升级到Net6的过程汇报

    目       录 1..... 概述... 1 2..... 升级的工程... 3 3..... 升级的代码差异... 4 4..... 系统运行... 5 1.   概述 我们团队一直在工业领域从 ...

  4. spring的事务是如何回滚的、事务传播?

    实际上也是问的这个问题  spring的事务管理是如何实现的?总: spring的事务是由aop来实现的,首先要生成具体的代理对象,然后按照aop的整套流程来执行具体的操作逻辑,正常情况下要通过通知来 ...

  5. scrapy爬取《坏蛋是怎样练成的4》

    scrapy具体介绍就不用说了,自己百度一下.或者参考以下文档 https://blog.csdn.net/u011054333/article/details/70165401 直接在cmd里运行 ...

  6. RFC3918协议测试——网络测试仪实操

    一.简介1.RFC3918简介历史· 在1999年3月成为正式标准 功能· 评测网络互连设备或网络系统的性能· 网络设备: 交换机,路由器- 内容· 定义了一整套测试方法,为不同厂家的设备/系统提供了 ...

  7. 不需要高价购买BI工具,掌握这个Excel插件就能碾压大数据

    ​曾几何时,EXCEL在数据界可谓是独树一帜,引领风骚,在职场中无人不知,无人不晓.但是随着大数据的出现,EXCEL便风光不再,江河日下,一度被其他大数据工具挤到了后面,逐渐被边缘化了.而我是一个EX ...

  8. 案例一:shell脚本指定日期减去一天

    如果只减去一天的话,直接写就可以了. #date -d"yesterday 20150401" +%Y%m%d 如果要减去几天,还可以这样写,如果用负数是往前数, #date -d ...

  9. 华为服务器设置iBMC管理网口IP地址,开启Monitor图文教程

    设置iBMC管理网口IP地址 默认用户名:root 默认密码:Huawei12#$ 操作步骤 服务器重启时,当出现如下界面时,重复按"Delete". 在启动过程出现输入密码对话框 ...

  10. 在vs2022环境中用C#创建COM组件

    规则 com组件以接口的方式对外开放. 1:所要导出的类必须为公有: 2:所有属性.方法也必须为公有: 3:要导出的属性.方法必须用接口方式: interface IName { [DispId(1) ...