Service start, stop, restart – nginx in centos

This simple guide explains you how to start, stop, restart the nginx service.

If you installed the nginx web server by using repository in centos, then follow the below commands
To start the nginx server

/etc/init.d/nginx start

To stop the nginx server

/etc/init.d/nginx stop

To restart the nginx server

/etc/init.d/nginx restart

To start/stop the nginx server at every system reboot

Install chkconfig package

yum install chkconfig

To start

chkconfig nginx on

To stop

chkconfig nginx off

More Information

To make sure that nginx service is running / stopped, use the following command

[ nginx]# ps aux |grep nginx
root 2117 0.0 0.1 41500 980 ? Ss 12:02 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 2118 0.0 0.2 41892 1708 ? S 12:02 0:00 nginx: worker process
root 2171 0.0 0.1 61176 764 pts/1 R+ 12:40 0:00 grep nginx

If you get response for the “ps” command, then the nginx service is running, else it’s not running

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Add a Comment

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