重新加载nginx配置

dev*_*691 38 configuration webserver nginx

我试图在Nginx conf文件中进行修改以删除"重写".

现在我有了这个配置文件:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen      80;
        server_name amc.local;
        return 301 https://$host:8443/index.html;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我想重新加载这个conf文件,我试过了

nginx -s reload
nginx -c <conf file>
nginx -s stop/start
Run Code Online (Sandbox Code Playgroud)

在日志文件中有行2014/01/22 11:25:25 [通知] 1310#0:信号处理开始

但修改不是负载.

cns*_*nst 62

也许你不是以root身份做的?

试试sudo nginx -s reload,如果它仍然不起作用,你可能想尝试sudo pkill -HUP nginx.


Moh*_*ady 27

如果你的系统有 systemctl

sudo systemctl reload nginx
Run Code Online (Sandbox Code Playgroud)

如果你的系统支持service(使用debian/ubuntu)试试这个

sudo service nginx reload
Run Code Online (Sandbox Code Playgroud)

如果不是(使用centos/fedora/etc),您可以尝试使用init脚本

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

  • 没有服务的等价物是`/etc/init.d/nginx reload`.据我所知,会在centos和debian上工作. (2认同)