Linux

Restart Nginx on Ubuntu, Centos and Docker

[ad_1]

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 user to run below shown commands.

Restart Nginx HTTP server

CentOS 7,  Ubuntu 18.04  and Ubuntu16.04 are a systemd operating system. To restart nginx service, you’ll need to use systemctl command line tool.

It is recommended to check syntax before restarting nginx service,

If you’re restarting after modifying nginx service unit file, you need to reload systemd first

Then restart nginx

If you want to reload the configuration without restarting the service, i.e maintain current sessions, use

Restarting Nginx on Upstart/SysV init system

If you’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 service command.

You can also use an absolute path to init script, e.g

Restarting Nginx inside docker container

For nginx running inside a Docker container, it is advisable to reload the configuration instead of restarting the service.

If you must restart the nginx process, then consider restarting the container using the command:

Example

Where nginx is the name of nginx container.

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

[ad_2]

Facebook Comments

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button