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 讲》

相关推荐
KnowFlow企业知识库7 分钟前
KnowFlow v2.3.0 重磅发布:适配 RAGFlow v0.22.1 和 MinerU v2.6.5、新增支持多模态视频解析,让知识库"看见"更多
linux·github
悟空空心8 分钟前
服务器长ping,traceroute
linux·服务器·网络·ssh·ip·ping++
此生只爱蛋35 分钟前
【Linux】正/反向代理
linux·运维·服务器
qq_54702617941 分钟前
Linux 基础
linux·运维·arm开发
yuhaiqun198942 分钟前
Typora 技能进阶:从会写 Markdown 到玩转配置 + 插件高效学习笔记
经验分享·笔记·python·学习·学习方法·ai编程·markdown
zfj3211 小时前
sshd除了远程shell外还有哪些功能
linux·ssh·sftp·shell
我只会发热1 小时前
Ubuntu 20.04.6 根目录扩容(图文详解)
linux·运维·ubuntu
爱潜水的小L1 小时前
自学嵌入式day34,ipc进程间通信
linux·运维·服务器
保持低旋律节奏1 小时前
linux——进程状态
android·linux·php
zhuzewennamoamtf1 小时前
Linux I2C设备驱动
linux·运维·服务器