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

本文将介绍如何在 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. 【CF632F】Magic Matrix(生成树 脑洞)

    题目链接 大意 给定一个\(N\times N\)的矩阵,问是否满足以下三个条件: \(A_{i,i}=0\) \(A_{i,j}=A_{j,i}\) 对于任意的\(i,j,k\),满足\(A_{i, ...

  2. pycharm关闭pytest

    在pycharm中,如果py文件以 test 开头,则运行时会使用pytest执行,pycharm关闭pytest方式如下 File -> Settings -> Tools -> ...

  3. python基础语法_字符串编码

    Python常用字符编码 http://www.cnblogs.com/schut/p/8406897.html   Python常见字符编码间的转换   在字符串写入文件时,有时会因编码问题导致无法 ...

  4. 《PHP程序员面试笔试宝典》——如何回答技术性的问题?

    如何巧妙地回答面试官的问题? 本文摘自<PHP程序员面试笔试宝典> 程序员面试中,面试官会经常询问一些技术性的问题,有的问题可能比较简单,都是历年的面试.笔试真题,求职者在平时的复习中会经 ...

  5. Solution -「ARC 125E」Snack

    \(\mathcal{Description}\)   Link.   把 \(n\) 种零食分给 \(m\) 个人,第 \(i\) 种零食有 \(a_i\) 个:第 \(i\) 个人得到同种零食数量 ...

  6. 暑假撸系统3- petty热更新 mybatis自动填充时间字段!

    经过了昨天纠结技术选型,和一大堆xml配置,终于把架子搭好了.因为最近一次做java项目也在好多年以前了(毕竟用了pytohn以后谁也不想再回来java了),java的生态发生了长足的进步,本来想从原 ...

  7. 面渣逆袭:二十二图、八千字、二十问,彻底搞定MyBatis!

    大家好,我是老三,面渣逆袭系列继续,这节我们的主角是MyBatis,作为当前国内最流行的ORM框架,是我们这些crud选手最趁手的工具,赶紧来看看面试都会问哪些问题吧. 基础 1.说说什么是MyBat ...

  8. 超简单集成华为 HMS MLKit 机器学习服务:银行卡识别 SDK,一键实现银行卡绑定

    前言 小编前面几期文章分别给大家介绍了使用 HMS ML Kit SDK 实现微笑抓拍.证件照 DIY.拍照翻译的功能开发(链接见文章末尾),本次小编给大家带来的是使用 HMS 机器学习服务(ML K ...

  9. BI报表系统该如何集成到其他系统呢?

    近期小麦我经常收到很多用户的反馈,想知道Smartbi的报表能不能从微信/钉钉之类的直接跳转到已做好的报表页面?他们都希望通过这种方式尽可能地避免由于各个管理软件账号密码不同而造成的不便,能够在日常工 ...

  10. petite-vue源码剖析-为什么要读源码?

    什么是petite-vue? 根据官方解释,petite-vue是专门为非前后端分离的历史项目提供和Vue相近的响应式开发模式. 与完整的Vue相比最大的特点是,面对数据的变化petite-vue采取 ...