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

相关推荐
wdxylb4 小时前
云原生俱乐部-shell知识点归纳(1)
linux·云原生
飞雪20075 小时前
Alibaba Cloud Linux 3 在 Apple M 芯片 Mac 的 VMware Fusion 上部署的完整密码重置教程(二)
linux·macos·阿里云·vmware·虚拟机·aliyun·alibaba cloud
路溪非溪6 小时前
关于Linux内核中头文件问题相关总结
linux
Lovyk8 小时前
Linux 正则表达式
linux·运维
好望角雾眠8 小时前
第一阶段C#基础-10:集合(Arraylist,list,Dictionary等)
笔记·学习·c#
艾伦~耶格尔8 小时前
【集合框架LinkedList底层添加元素机制】
java·开发语言·学习·面试
星仔编程9 小时前
python学习DAY46打卡
学习
Fireworkitte9 小时前
Ubuntu、CentOS、AlmaLinux 9.5的 rc.local实现 开机启动
linux·ubuntu·centos
大霞上仙9 小时前
实现自学习系统,输入excel文件,能学习后进行相应回答
python·学习·excel
sword devil90010 小时前
ubuntu常见问题汇总
linux·ubuntu