How to restart, shutdown, and start nginx server?

FreeBSD comes with Nginx startup script located at /usr/local/etc/rc.d directory.
Update /etc/rc.conf

All you have to do is add following line to your /etc/rc.conf file:

nginx_enable=”YES”
Once added use the following command to control nginx web server. You must be root user to control nginx.
Start Nginx Web Server Command

# /usr/local/etc/rc.d/nginx start
Stop Nginx Web Server Command

# /usr/local/etc/rc.d/nginx stop
Restart Nginx Web Server Command

# /usr/local/etc/rc.d/nginx restart
Test Nginx config file for errors

The -t option will just test the configuration file. nginx checks configuration for correct syntax and then try to open files referred in configuration.
# nginx -c /usr/local/etc/nginx/nginx.conf -t

Once statisfied, restart / start Nginx:
# /usr/local/etc/rc.d/nginx start
The -c /path/to/config/file specifies which configuration file Nginx should use instead of the default.

Share
This entry was posted in Linux Tricks. Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>