How can I restart nginx web server on Linux?
In order restart nginx web server, you can use any of the next commands. Make sure you run this commands with root privileges:
service nginx restart
or
/etc/init.d/nginx restart
However, be aware that restarting Nginx webserver may interrupt all active connections. For this case, it is better to reload nginx, instead of restarting.
The following reload ngix command should work on most popular linux distributions like CentOS, RHEL, Fedora, Debian or Ubuntu:
nginx -s reload
or
/usr/local/nginx/sbin/nginx -s reload
or
/etc/init.d/nginx reload
If you are using CentOS 7, which uses systemd, you should restart nginx webserver using systemctl command by running:
systemctl restart nginx.service
As you see, you can restart and reload nginx easily from the command line from most linux systems. You should only restart nginx if you have applied changes to nginx.conf configuration file, although a simple reload should be enough too.