j0h*_*j0h 20 debian systemd nginx
我刚刚在 Debian 8 服务器上安装了 nginx 1.9。nginx 工作正常,当我告诉它运行时,但它似乎不会在启动时自动加载 nginx。
我已经尝试了互联网上推荐的许多 init 脚本,但还没有奏效。所以现在我试图用 systemctl 来解决这个问题。
~$ systemctl status nginx
? nginx.service
Loaded: masked (/dev/null)
Active: inactive (dead)
~$ sudo systemctl try-restart nginx
Failed to try-restart nginx.service: Unit nginx.service is masked.
~$ sudo systemctl reload nginx
Failed to reload nginx.service: Unit nginx.service is masked.
~$ sudo systemctl reload nginx
Failed to reload nginx.service: Unit nginx.service is masked.
Run Code Online (Sandbox Code Playgroud)
不幸的是,我不知道“服务被屏蔽”是什么意思,也不知道为什么要屏蔽。
当我跑
sudo nginx
Run Code Online (Sandbox Code Playgroud)
服务器运行得很好。然后,我研究了揭开 nginx 服务的掩码。
~$ sudo systemctl unmask nginx.service
Removed symlink /etc/systemd/system/nginx.service.
Run Code Online (Sandbox Code Playgroud)
好的,现在我可以使用 systemctl 启动 nginx。所以我检查了重启是否会自动加载 nginx。但它没有这样做,我不知道从哪里开始。
有人可以帮助我在启动时自动运行 nginx 吗?
int*_*lfx 21
您似乎混淆了启用、启动和屏蔽操作。
systemctl start,systemctl stop:开始(停止)的单元中的问题立即;systemctl enable, systemctl disable: 标记(取消标记)启动时自动启动的单元(以特定于单元的方式,在其[Install]部分中描述);systemctl mask, systemctl unmask: 禁止(允许)所有和任何尝试启动有问题的单元(手动或作为任何其他单元的依赖项,包括默认引导目标的依赖项)。请注意,systemd 中的自动启动标记是通过从默认引导目标添加到相关单元的人工依赖项来实现的,因此“掩码”也不允许自动启动。所以,这些都是不同的操作。其中,您想要systemctl enable.
参考:systemctl(1)。
更多:Lennart Poettering (2011-03-02)。 “三关”。 systemd 为管理员。0pointer.de。
我忽略了该文档的大部分内容,该文档专门用于编译 nginx 的其他版本,并转到“使其自动启动”。
我按照那里的指示进行操作,现在当我重新启动时,nginx 1.9 正在运行。
我非常感谢大家的帮助和见解。谢谢你们!
| 归档时间: |
|
| 查看次数: |
57728 次 |
| 最近记录: |