Install Nginx on FreeBSD

Written by
Date: 2015-01-14 22:33:00 00:00


How to install Nginx web server on FreeBSD

You can install it will the default options with just a command:

pkg install nginx

But as I prefer to have gzip_static module enable to gzip files on the fly, I would rather install by compiling it from ports, I love this possibility that I mainly enjoy on Arch Linux and Gentoo.

Firts thing is to be sure the ports files are up to date, so run:

portsnap fetch update

Now we can install Nginx web server on our FreeBSD system

cd /usr/ports/www/nginx
make install clean

Look for this line in the screen that will be presented to you.

[ ] HTTP_GZIP_STATIC_MODULE   Enable http_gzip_static module

And be sure to check it, it should now look like this:

[X] HTTP_GZIP_STATIC_MODULE   Enable http_gzip_static module

Accept the rest of default options or change them according to your needs, and you are done, Nginx is installed.

You are now free to start configuring it, the configuration file is at:

/usr/local/etc/nginx/nginx.conf

To make it run at start time run this command:

echo 'php_fpm_enable="YES"' >> vi /etc/rc.conf