在 Ubuntu 上使用源码安装 OpenResty
镜像下载、域名解析、时间同步请点击 阿里云开源镜像站
本文将介绍如何在 Ubuntu 上使用源码安装 OpenResty。
目标
- Ubuntu 18.04
- OpenResty 1.19.3.2
安装依赖
- 启用 HTTP 基本状态模块:
--with-http_stub_status_module - 启用 HTTP gzip 静态文件压缩模块:--with-http_gzip_static_module
- 启用 HTTP/2 模块:--with-http_v2_module
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>
一键安装脚本
本文转自:https://segmentfault.com/a/1190000040325948
在 Ubuntu 上使用源码安装 OpenResty的更多相关文章
- ubuntu php5.6源码安装
本系列的lnmp的大框架基本上是按照http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan ...
- 使用Notepad++远程编辑Ubuntu上的源码
简单搭建了在Windows上远程编辑Ubuntu Server 14.04上面源代码的环境,记录一下,给需要的人. Notepad++安装NppFTP 从插件菜单打开PluginManager,选中N ...
- [笔记] Ubuntu 18.04源码安装caffe流程
虽然Ubuntu 18.04可以通过apt安装caffe,但是为了使用最新的代码,还是值得从源码安装一遍的. 安装环境 OS: Ubuntu 18.04 64 bit 显卡: NVidia GTX 1 ...
- ubuntu mysql5.7源码安装
本系列的lnmp的大框架基本上是按照http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan ...
- 在CentOS7上源码安装OpenResty
您必须将这些库perl 5.6.1+libreadlinelibpcrelibssl安装在您的电脑之中. 对于 Linux来说, 您需要确认使用 ldconfig 命令,让其在您的系统环境路径中能找到 ...
- ubuntu上用源码进行一键安装mysql
首先卸载原有的mysql: 首先查看自己的mysql有哪些依赖 #dpkg --list|grep mysql 先卸载 #sudo apt-get remove mysql-common #sud ...
- 简单说说Ubuntu利用bzr源码安装OpenERP7.0的操作步骤
1.修改Ubuntu国内更新源,具体方法自己baidu.google. 修改更新源后,更新系统 sudo apt-get update sudo apt-get upgrade 复制代码 2.安装Po ...
- centos 7 源码安装openresty
Openresty 官网 http://openresty.org Openresty源码下载页面 http://openresty.org/en/download.html Openresty 简易 ...
- ubuntu vim8.0源码安装
安装篇 从https://github.com/vim/vim下载相应zip源码文件,利用unzip vim-master.zip 命令解压到当前用户目录,即~: 解压后进入vim的src目录,首先, ...
随机推荐
- 猪齿鱼平台常用前端css实现方案
居中 最常用的height + line-height,以及margin:0 auto的居中方式就不再阐述,以下介绍两种容错性高的实现方案. flex布局实现 猪齿鱼前端日常开发中,我们多以fle ...
- docker基础——3.存储卷
把宿主机的目录或文件链接到容器的目录或文件,可以避免写时复制对高I/O操作的影响,也避免容器销毁时数据丢失. 1. 只指定容器的目录位置,-v docker run -it --name bbox1 ...
- MLlib学习——基本统计
给定一个数据集,数据分析师一般会先观察一下数据集的基本情况,称之为汇总统计或者概要性统计.一般的概要性统计用于概括一系列观测值,包括位置或集中趋势(比如算术平均值.中位数.众数和四分位均值),展型(比 ...
- 帆软报表(finereport)雷达图钻取详细点新页面展示
添加参数栏,季度下拉框的空间名为combobox0 添加雷达图,通过第三页面做跳转 雷达图钻取.cpt为联动钻取的第三页面 添加纬度(所点击钻取的点) 参数 wd 添加季度参数 jd 值为季 ...
- 01网络编程(基础知识+OSI七层协议+TCP与UDP)
目录 01 网络编程 一.软件开发架构 1.1 CS架构 1.2 BS架构 二.网络理论前戏 2.1 简介 2.2 常见硬件 三.OSI七层协议(五层) 3.1 七层协议 3.2 五层协议 3.3 知 ...
- HTML5知识点笔记
1.HTML是一种标记语言 2.HTML元素不区分大小写 //可以在xss绕过waf时使用 3.<code></code>为空元素标签 <code/>为自闭合标签 ...
- Python基础—基础数据类型list(Day4)
基础数据类型 四.list列表 存放大量数据,大量的数据在列表中便于操作,列表示有序的,有索引值,可切片,方便取值. 1.list的增 1).append('元素') 在列表后面按元素添加 ...
- [LeetCode]1389. 按既定顺序创建目标数组
给你两个整数数组 nums 和 index.你需要按照以下规则创建目标数组: 目标数组 target 最初为空. 按从左到右的顺序依次读取 nums[i] 和 index[i],在 target 数组 ...
- Android SugarORM(4)
Android Sugar ORM(4) Android Sugar ORM 数据库迁移 据官网描述, Sugar ORM的设计灵感来自与Rails(没用过, 咱也不知道是啥, 以后也许会学到吧)迁移 ...
- CobaltStrike逆向学习系列(2):Stageless Beacon 生成流程分析
这是[信安成长计划]的第 2 篇文章 关注微信公众号 [信安成长计划] 0x00 目录 0x01 Patch Beacon 0x02 Patch Loader 0x03 文件对比 0x04 流程图 C ...