在Ubuntu 20上,你可以使用systemd来管理OpenResty服务。以下是一种可能的步骤:

首先,创建一个systemd服务文件,例如 /etc/systemd/system/openresty.service,并编辑它:

[Unit]
Description=OpenResty nginx server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

这个文件定义了启动、重载和停止OpenResty的命令。注意,你可能需要根据你的OpenResty安装位置调整路径。

然后,你需要告诉systemd你添加了一个新的服务:

sudo systemctl daemon-reload

现在,你可以使用以下命令启动OpenResty:

sudo systemctl start openresty

检查OpenResty的状态:

sudo systemctl status openresty

如果你想让OpenResty在启动时自动运行,你可以使用以下命令:

sudo systemctl enable openresty

这就是在Ubuntu 20使用systemd管理OpenResty服务的基本方法。


香港五网CN2网络云服务器链接:www.tsyvps.com

蓝易云香港五网CN2 GIA/GT精品网络服务器。拒绝绕路,拒绝不稳定。

蓝易云是一家专注于香港及国内数据中心服务的提供商,提供高质量的服务器租用和云计算服务、包括免备案香港服务器、香港CN2、美国服务器、海外高防服务器、国内高防服务器、香港VPS等。致力于为用户提供稳定,快速的网络连接和优质的客户体验。
最后修改:2023 年 08 月 28 日
如果觉得我的文章对你有用,请随意赞赏