80

I am trying to modify the Nginx config file to remove a "rewrite".

Currently, I have this config file:

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;
    }
}

Now I want to reload this config file, I tried

nginx -s reload
nginx -c <conf file>
nginx -s stop/start

In the log file, there is the line

2014/01/22 11:25:25 [notice] 1310#0: signal process started

but the modifications are not loaded.

2 Answers 2

130

Maybe you're not doing it as root?

Try sudo nginx -s reload, if it still doesn't work, you might want to try sudo pkill -HUP nginx.

2
  • 1
    Even on Bitnami LAMP Stack, this method is working! Thank you Commented Jul 24, 2016 at 16:41
  • @GangsarSwaPurba, glad it works! It should work pretty much on any UNIX system, since it does not depend on any proprietary frameworks or system-specific scripts!
    – cnst
    Commented Jul 24, 2016 at 16:48
56

If your system has systemctl

sudo systemctl reload nginx

If your system supports service (using debian/ubuntu) try this

sudo service nginx reload

If not (using centos/fedora/etc) you can try the init script

sudo /etc/init.d/nginx reload
5
  • 2
    An equivalent without service is /etc/init.d/nginx reload. Would work on centos and debian as far as i know.
    – Lightbulb1
    Commented Jun 24, 2014 at 13:39
  • debian distros prefer the service keyword, some packages even give a warning if you use the init.d script, so I usually use the service and fall back to init.d if it doesn't work, either ways I'll add this tip to my answer Commented Jun 24, 2014 at 13:41
  • Thats interesting. I've never seen a warning. I always thought service ran the scripts in /etc/init.d/. I prefer service because its easier to type. Whats the technical reason for there being a warning thrown?
    – Lightbulb1
    Commented Jun 24, 2014 at 13:47
  • Thank you. That makes allot of sense. Also i found this http://www.tutorialspoint.com/unix_commands/service.htm i think its just the man pages, but it does explain how service create a minimal environment to run the scrips in. I guess it can help them run consistently between different distros.
    – Lightbulb1
    Commented Jun 24, 2014 at 13:57
  • It would work when you have a service for Nginx. The question is about the Nginx execution file not a service one...
    – Ario
    Commented Nov 18, 2016 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.