在 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目录,首先, ...
随机推荐
- LeetCode随缘刷题之整数反转
package leetcode.day_01_29; /** * 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果. * 如果反转后整数超过 32 位的有符号整数的范围[− ...
- Solution -「CF 1372E」Omkar and Last Floor
\(\mathcal{Description}\) Link. 给定一个 \(n \times m\) 的矩阵,每行被划分为若干段,你可以钦定每段中恰好一个位置为 \(1\),其余位置为 \( ...
- MySQL架构原理之体系架构
MySQL是最流行的关系型数据库软件之一,由于其体量小.速度快.开源免费.简单易用.维护成本低等,在季军架构中易于扩展.高可用等优势,深受开发者和企业的欢迎,在互联网行业广泛使用. 其系统架构如下: ...
- curl常用参数详解及示例
curl简介 curl是一个开源的命令行工具,它基于网络协议,对指定URL进行网络传输,得到数据后不任何具体处理(如:html的渲染等),直接显示在"标准输出"(stdout)上. ...
- [题解]hihoCoder挑战赛18——题目1 神奇字符串
题目地址:http://hihocoder.com/problemset/problem/1264 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 我们说两个字符串是非常 ...
- 教你快速区分传统报表和商业智能BI
很多人分不清楚,传统报表和商业智能BI之间的区别?有些人认为,BI就是做报表的,其实不然,报表只是BI的一部分,报表是关于过去和现状的展示,而BI是关于如何通过分析数据,帮助决策者找到改变和提高的方案 ...
- Excel真的是三维地图可视化制作最好的选择吗?
随着数据在当下互联网快速发展下变的维度更广,数量更大.结构越来越复杂,人们想要更加清晰,快速的认知和理解一份数据,传统的二维平面图表已经不能满足需求,三维可视化技术越结合多媒体技术.网络技术以及三维镜 ...
- 【windows 访问控制】开篇、访问控制模型模型
访问控制模型的各个部分 访问控制模型有两个基本部分: 访问令牌,其中包含有关已登录用户的信息 安全描述符,其中包含用于保护安全对象 的安全信息 用户登录时 ,系统会对用户 的帐户名和密码进行身份验证. ...
- c# $ @特殊字符
c# @ 停止字符串中的转义字符,让字符串内的转义字符当正常字符输入. 因此,如果你需要类似"所见所得"效果的赋值,逐字字符串赋值方式会是你的首选!此外,需要注意的是,当使用符号 ...
- Windows11中如何使用旧版本IE浏览器打开网页
Windows11删除了旧版本IE浏览器,完全采用了Edge,但是我们进行网站测试时有时仍会用到IE浏览器,那么可以按照以下步骤启用: 1.进入Edge浏览器中,打开设置,进入默认浏览器选项下: 修改 ...