How to install Nginx on FreeBSD

Prereqs

Install Nginx

pkg install nginx

If you are using either the csh or tcsh shell, make sure to run the rehash command. This makes the shell aware of the new applications you installed:

rehash

Enable Nginx at boot

To start service use

rc
FreeBSD utility that controls the system’s automatic boot processes. Scripts for every service available on the system are located in the
 /usr/local/etc/rc.d 

grep rcvar /usr/local/etc/rc.d/*

It should return a list similar to this


/usr/local/etc/rc.d/cloudconfig:rcvar="cloudinit_enable" /usr/local/etc/rc.d/cloudfinal:rcvar="cloudinit_enable" /usr/local/etc/rc.d/cloudinit:rcvar="cloudinit_enable" /usr/local/etc/rc.d/cloudinitlocal:rcvar="cloudinit_enable" /usr/local/etc/rc.d/nginx:rcvar=nginx_enable /usr/local/etc/rc.d/rsyncd:rcvar=rsyncd_enable

For Nginx the rcvar is nginx_enable.
Enable nginx to run at boot time:

sysrc nginx_enable=“YES”

sysrc
is a convenience tool for interacting with the /etc/rc.conf file.

or

edit

/etc/rc.conf
file with
sudo
privileges and editor of choice.

sudo ee /etc/rc.conf

nginx_enable="YES" firewall_enable="YES" firewall_type="workstation" firewall_myservices="22/tcp 80/tcp 443/tcp" firewall_allowservices="any"

some additonal parameters to be added

https://forums.freebsd.org/threads/nginx-multiple-domain-1-ip.42444/

https://www.linuxhelp.com/how-to-configure-nginx-virtualhost-in-freebsd

https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/

https://www.cyberciti.biz/faq/freebsd-install-nginx-webserver/

https://zaiste.net/posts/freebsd-installing-nginx/

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-freebsd-11-2

https://www.linuxbabe.com/nginx/what-are-spdy-and-http2-and-how-to-enable-them-on-nginx

https://serverfault.com/questions/707955/nginx-split-large-configuration-file

certs

https://letsencrypt.org/docs/

https://github.com/acmesh-official/acme.sh

https://github.com/srvrco/getssl

https://go-acme.github.io/lego/