Linux学习之Ubuntu 20使用systemd管理OpenResty服务

sudo cat /etc/issue可以看到操作系统的版本是Ubuntu 20.04.4 LTSsudo lsb_release -r可以看到版本是20.04sudo uname -r可以看到内核版本是5.5.19sudo make -v可以看到版本是GNU Make 4.2.1

需要先参考我的博客《Linux学习之Ubuntu 20.04在https://openresty.org下载源码安装Openresty 1.19.3.1,使用systemd管理OpenResty服务》安装好Openresty

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

bash 复制代码
[Unit]
Description=The OpenResty Application
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

sudo systemctl enable openresty设置自启动,sudo systemctl start openresty启动openrestysudo systemctl status openresty查看到状态是active (running)

在浏览器里边输入服务器ip,要是正常配置好的话,显示如下:

此文章为8月Day 26学习笔记,内容来源于极客时间《Linux 实战技能 100 讲》

相关推荐
hujun861011 小时前
Ubuntu安装无线网卡
linux
Johny_Zhao12 小时前
CentOS Stream 8 高可用 Kuboard 部署方案
linux·网络·python·网络安全·docker·信息安全·kubernetes·云计算·shell·yum源·系统运维·kuboard
Roc-xb13 小时前
/etc/profile.d/conda.sh: No such file or directory : numeric argument required
python·ubuntu·conda
卖猪肉的痴汉14 小时前
1.1 Linux 编译FFmpeg 4.4.1
linux·ffmpeg
十五年专注C++开发14 小时前
Qt .pro配置gcc相关命令(三):-W1、-L、-rpath和-rpath-link
linux·运维·c++·qt·cmake·跨平台编译
Chef_Chen14 小时前
从0开始学习语言模型--Day02-如何最大化利用硬件
人工智能·学习·语言模型
qq_6285157614 小时前
Centos与RockLinux设置静态ip
linux·运维·centos
LuLaLuLaLeLLLLLL15 小时前
Elastic Search 学习笔记
笔记·学习
Jack魏15 小时前
React学习001-创建 React 应用
前端·学习·react.js
程序猿小D15 小时前
第27节 Node.js Buffer
linux·开发语言·vscode·node.js·c#·编辑器·vim