FreeBSD Install Nginx Webserver

How do I install an Nginx webserver under a FreeBSD Unix operating system?

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.

Update FreeBSD ports tree

Type the following command to update FreeBSD tree, enter:
# portsnap fetch update
Sample outputs:

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... 

Install Nginx using FreeBSD ports

Type the following command to install the Nginx web server port:
# cd /usr/ports/www/nginx/
# make install clean

Fig.01 FreeBSD install Nginx Using the Port
Fig.01 FreeBSD install Nginx Using the Port

Make sure you select important option such as REWRITE_MODULE, SSL_MODULE and others as per your requirements.

Install nginx using the pkg command

Add the binary package using the following command:
# pkg install nginx
Sample outputs:

Fig.02: Add the package
Fig.02: Add the package

Turn on Nginx Webserver Service

Type the following command to turn on Nginx server
# echo 'nginx_enable="YES"' >> /etc/rc.conf

How do I start an nginx server?

To start Nginx, enter:
# /usr/local/etc/rc.d/nginx start
OR
# service nginx start
Sample outputs:

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
Starting nginx.

How do I stop an nginx server?

# /usr/local/etc/rc.d/nginx stop
OR
# service nginx stop

How do I restart an nginx server?

# /usr/local/etc/rc.d/nginx restart
OR
# service nginx restart

How do I reload an nginx server after config file changes?

# /usr/local/etc/rc.d/nginx reload
OR
# service nginx reload

Important Information about Nginx webserver on a 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)

Testing the setup

Type the following url in your web-browser:
http://server-ip-here/
OR your domain name:
http://nixcraft.com/
Sample outputs:

Fig.03: Nginx in action
Fig.03: Nginx in action
Posted on: October 16, 2017, by :  | 29 views

Leave a Reply

https://serang.ut.ac.id/css/css/slot88/ https://tinjut.bagkeu.dikdasmen.kemdikbud.go.id/slot-maxwin/ https://dpm.polinema.ac.id/slot-gacor/ https://akademik.ft.unm.ac.id/slot-dana/ https://ppdb.probolinggokab.go.id/slot-5000/ https://bkad.sulselprov.go.id/assets/ https://ojs.balidwipa.ac.id/docs/slot-gacor/ http://korpri.pekalongankab.go.id/api/slot-gacor/ https://elang.umpp.ac.id/foto/farmasi/-/asset/ http://rsud-kelet.jatengprov.go.id/wp-content/-/asset/ https://kusdhianto-fe.staff.ugm.ac.id/slot88/ http://ppdb.probolinggokab.go.id/judi-bola/ https://bapenda.labuhanbatukab.go.id/racikan-sbobet/ http://rsud-kelet.jatengprov.go.id/wp-content/-/data/ https://agenda.riau.go.id/-/judi-bola/ https://balapan.padang.go.id/sbobet88/ http://jdih.wakatobikab.go.id/sbobet88/ http://kph.menlhk.go.id/sbobet88/ https://bkad.sulselprov.go.id/data/ https://dpm.polinema.ac.id/slot-gacor/ https://dinkes.jemberkab.go.id/storage/attachments/