小编Rom*_*man的帖子

重启后自动启动nginx

我正在使用 crontab 在重新启动后启动一些服务。

这是我当前的 crontab:

@reboot root /etc/init.d/nginx reload
@reboot /usr/local/bin/forever start /var/www/rtc/index.js
Run Code Online (Sandbox Code Playgroud)

它适用于forever,但 nginx 永远不会启动。

我也试过:

@reboot /etc/init.d/nginx reload
@reboot sudo service nginx reload
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

我的 nginx conf 如下所示:

server {
        listen 443 ssl;
        server_name www.example.com;

        ssl_certificate /var/wwwssl/example.pem;
        ssl_certificate_key /var/wwwssl/example.key.pem;

        location / {
                proxy_pass https://www.example.com:8443;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }
}
Run Code Online (Sandbox Code Playgroud)

编辑:

此解决方案也不起作用

使用 systemd 插件来做到这一点:

[Service]
Restart=always
Run Code Online (Sandbox Code Playgroud)

您将其作为文件放置/etc/systemd/system/nginx.service.d/override.conf(如果目录不存在,则创建该目录)。您也可以使用systemctl edit nginx来创建文件。 …

server cron nginx

6
推荐指数
1
解决办法
4274
查看次数

标签 统计

cron ×1

nginx ×1

server ×1