2

I made a new conf file in sites-available (and linked it in sites-enabled) and now I want to "install" that conf file without resetting the nginx server.

As root, I can run nginx -c file.conf since that almost does what I want; however, the conf files in sites-enabled seem to run within some other defined context when nginx starts because I always get the following error when running that command:

$ nginx -c /etc/nginx/sites-available/alpha
2010/09/30 02:32:13 [emerg] 31769#0: unknown directive "server" in sites-available/alpha:1

How can I dynamically run this new conf file?

$ nginx -v
nginx version: nginx/0.6.32
$ cat /etc/issue
Debian GNU/Linux squeeze/sid
$ cat /etc/nginx/sites-available/alpha
server {
    listen   443;
    server_name  XXX.net;

    ssl  on;
    ssl_certificate      /etc/nginx/certificates/server.crt;
    ssl_certificate_key  /etc/nginx/certificates/server.key;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;

    location / {
        proxy_pass   http://127.0.0.1:1338;
    }
}

I am using self-signed certificates.

Alexander Bird
  • 431
  • 2
  • 7
  • 14

4 Answers4

5

Run the following command:

/etc/init.d/nginx reload

(or, on newer debian/ubuntu):

service nginx reload
pauska
  • 19,620
  • 5
  • 57
  • 75
4
RABBITZ# nginx -h
...snip...
 -s signal     : send signal to a master process: stop, quit, reopen, reload
...snip...

So you can use OS independent command:

nginx -s reload
SaveTheRbtz
  • 5,691
  • 4
  • 32
  • 45
1

service nginx reload

Remember that reload is a gracefully way of any applying conf .It is more appropriate to use reload as it don't cause any downtime(restart causes some milisecs of downtime as it has to stop and then start again).

Werulz
  • 315
  • 1
  • 5
  • 16
0

Find PID of master process:

ps aux | grep nginx
root     22041  0.0  0.2   4808   684 ?        Ss   08:14   0:00 nginx: master process /usr/sbin/nginx
www-data 22042  0.0  0.4   4976  1044 ?        S    08:14   0:00 nginx: worker process
root     22044  0.0  0.3   3344   812 pts/1    S+   08:14   0:00 grep --color=auto nginx

And send HUP:

kill -HUP 22042
bindbn
  • 5,211
  • 2
  • 26
  • 24