{"id":1431,"date":"2018-10-23T05:30:03","date_gmt":"2018-10-23T05:30:03","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1431"},"modified":"2018-10-24T02:49:49","modified_gmt":"2018-10-24T02:49:49","slug":"restart-nginx-on-ubuntu-centos-and-docker","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/23\/restart-nginx-on-ubuntu-centos-and-docker\/","title":{"rendered":"Restart Nginx on Ubuntu, Centos and Docker"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/10\/linux-restart-nginx.png\" alt=\"linux restart nginx\" width=\"713\" height=\"341\" \/><\/p>\n<p>How often do you restart ngnix service on Linux webserver? This blog post will cover various ways to restart Nginx on a Linux system via command line and on Nginx running in a docker container. I have covered on both on a Systemd server and SysV init\/Upstart system.<\/p>\n<p>Open your terminal and login with root\/sudo user to run below shown commands.<\/p>\n<h2>Restart Nginx HTTP server<\/h2>\n<p>CentOS 7, Ubuntu 18.04 and Ubuntu16.04 are a systemd operating system. To restart nginx service, you&#8217;ll need to use <a href=\"https:\/\/linoxide.com\/linux-command\/linux-systemd-commands\/\" target=\"_blank\" rel=\"noopener\">systemctl command<\/a> line tool.<\/p>\n<p>It is recommended to check syntax before restarting nginx service,<\/p>\n<p>$ sudo nginx -t<br \/>\n$ sudo systemctl restart nginx<\/p>\n<p>If you&#8217;re restarting after modifying nginx service unit file, you need to reload systemd first<\/p>\n<p>$ sudo systemctl daemon-reload<\/p>\n<p>Then restart nginx<\/p>\n<p>$ sudo systemctl restart nginx<\/p>\n<p>If you want to reload the configuration without restarting the service, i.e maintain current sessions, use<\/p>\n<p>sudo systemctl reload nginx<\/p>\n<h2>Restarting Nginx on Upstart\/SysV init system<\/h2>\n<p>If you&#8217;re running a system with upstart or SysV init system. e.g Ubuntu 14.04, CentOS 6, you need to manage nginx service using the servicecommand.<\/p>\n<p>$ sudo service nginx restart<\/p>\n<p>You can also use an absolute path to init script, e.g<\/p>\n<p>sudo \/etc\/init.d\/nginx restart<\/p>\n<h2>Restarting Nginx inside docker container<\/h2>\n<p>For nginx running inside a Docker container, it is advisable to reload the configuration instead of restarting the service.<\/p>\n<p>docker exec &lt;nginx-container-name-or-id&gt; nginx -s reload<\/p>\n<p>If you must restart the nginx process, then consider restarting the container using the command:<\/p>\n<p>$ docker restart &lt;container name|id&gt;<\/p>\n<p>Example<\/p>\n<p>$ docker restart nginx<\/p>\n<p>Where nginx is the name of nginx container.<\/p>\n<p>Restarting nginx is a simple process but you need to be careful to ensure that any change made has correct syntax to avoid failure during a restart. The command used to check for configuration syntax is nginx -t<\/p>\n<h3>Read Also:<\/h3>\n<ul>\n<li><a href=\"https:\/\/linoxide.com\/linux-how-to\/find-how-to-stop-and-restart-apache-on-linux-systems\/\" target=\"_blank\" rel=\"noopener\">Find How to Stop and Restart Apache on Linux Systems<\/a><\/li>\n<li><a href=\"https:\/\/linoxide.com\/linux-how-to\/how-restart-networking-ubuntu\/\" target=\"_blank\" rel=\"noopener\">How to Restart Networking in Ubuntu<\/a><\/li>\n<li><a href=\"https:\/\/linoxide.com\/how-tos\/how-restart-linux-system-reboot-command-line\/\" target=\"_blank\" rel=\"noopener\">How to Restart Linux System Using Reboot Command Line<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/linoxide.com\/linux-how-to\/how-restart-nginx-ubuntu-centos-docker\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How often do you restart ngnix service on Linux webserver? This blog post will cover various ways to restart Nginx on a Linux system via command line and on Nginx running in a docker container. I have covered on both on a Systemd server and SysV init\/Upstart system. Open your terminal and login with root\/sudo &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/23\/restart-nginx-on-ubuntu-centos-and-docker\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Restart Nginx on Ubuntu, Centos and Docker&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1431","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1431"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1431\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1431\/revisions\/1494"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}