nginx [engine x] is a HTTP server, reverse proxy and mail proxy server written by Igor Sysoev. It is a lightweight web server, licensed under a BSD-like license. It the fastest growing and one of the most popular web server.
Installing from FreeBSD ports tree
Type the following command to update FreeBSD tree, enter:
# portsnap fetch update
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching public key from your-org.portsnap.freebsd.org... done.
Fetching snapshot tag from your-org.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Fri Sep 9 05:32:42 IST 2016:
16ed4abfc9b7777b9ca5999867f5bfa793c7e1c1902b89100% of 71 MB 3978 kBps 00m18s
Extracting snapshot... done.
Verifying snapshot integrity...
Type the following command to install the Nginx web server port:
# cd /usr/ports/www/nginx/ # make install clean
You will be presented with the TUI that allows you to select the modules you want installed. I would suggest at minimum selecting REWRITE_MODULE, SSL_MODULE and possibly HTTP_GEOIP.
Installing from FreeBSD package manager PKG
Add the binary package using the following command:
# pkg install nginx
Enabling Nginx Webserver Service to start automatically at boot
Type the following command to turn on Nginx server
# echo 'nginx_enable="YES"' >> /etc/rc.conf
Or use the more appropriate sysrc tool which we=as
# sysrc nginx_enable="YES"
To start Nginx, enter:
# /usr/local/etc/rc.d/nginx start
# service nginx start
The following will scroll down the terminal confirming that the nginx config was tested to be syntactically correct.
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
To stop Nginx, enter:
# /usr/local/etc/rc.d/nginx stop
# service nginx stop
To restart Nginx, enter:
# /usr/local/etc/rc.d/nginx restart
# service nginx restart
Reload an nginx server after config file changes
# /usr/local/etc/rc.d/nginx reload
# service nginx reload
Before restarting or reloading Nginx its always worth running the configuration test command so that you can validate the syntax of the Nginx config. This will eliminate any unexpected downtime of your web server.
# /usr/local/etc/rc.d/nginx configtest>
# service nginx configtest
Default for Nginx on FreeBSD
Nginx Default configuration file: /usr/local/etc/nginx/nginx.conf
Nginx Default http / https port: 80 / 443
Nginx Default error log file: /var/log/nginx-error.log
Nginx Default access log file: /var/log/nginx-access.log
Nginx Default DocumentRoot: /usr/local/www/nginx/
Nginx service command: service nginx (start|stop|restart|reload|configtest|upgrade|gracefulstop|status|poll)