How to Restart Nginx Web Server On Ubuntu/CentOS
In this tutorial we are going to learn how to restart Nginx Web server on Ubuntu 16.04, CentOS 7 and Fedora from the command line.
Most of the Linux distributions now use systemctl command to manage services, this includes Ubuntu, CentOS 7, RedHat 7, Fedora and Debian Linux.
So you can use systemctl command to restart Nginx web server on Ubuntu/CentOS:
systemctl restart nginx.service
The systemctl command also has a reload option, which will reload Nginx configuration file without restarting the entire nginx server.
systemctl reload nginx
Manage Nginx service with systemctl command
You can also use the systemctl command to start, stop and enable nginx service in Ubuntu/CentOS 7.
To stop Nginx Web server, Type:
systemctl stop nginx.service
To start Nginx on Ubuntu, Type:
systemctl start nginx.service
To start nginx at system reboot, Type:
systemctl enable nginx.service
To view server status, execute:
systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-01-11 20:45:41 +0530; 1min 51s ago
Process: 1097 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1009 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1101 (nginx)
Tasks: 2
Memory: 7.5M
CPU: 198ms
CGroup: /system.slice/nginx.service
├─1101 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
└─1102 nginx: worker process
Jan 11 20:45:39 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 11 20:45:41 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.