How to install Nginx on FreeBSD

3 Jun

FreeBSD is fast and secure operating system and becoming my choice for server production of this year. Nginx (engine x) is one of the most popular and fastest growing web servers in the world, it has reach 42% market share at June 2019 reported by w3techs. FreeBSD and Nginx is a powerful combination to achieve fast, secure, web server.

In this tutorial, we will learn how to install nginx on FreeBSD 12 from source. Before we start, please ensure that you have FreeBSD 12 running on your machine, and if not please refer to this article. Here we go:

First, we need to install some dependencies ant then download nginx source form nginx.org and we will use nginx version 1.17.0 (latest version by this date). I assume that you already logged in your server through ssh or console 🙂

$ sudo pkg install pcre libxml2 libxslt
  $ wget http://nginx.org/download/nginx-1.17.0.tar.gz

Then extract the source and enter to it’s directory

 $ tar -zxvf nginx-1.17.0.tar.gz
 $ cd nginx-1.17.0 

Then configure:

$ ./configure --prefix=/usr/local/nginx --with-threads --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_secure_link_module --with-stream_geoip_module --with-http_xslt_module --with-debug

Please wait until it’s done. Next compile it and install:

$ make
$ sudo make install

You’ll found this line when it’s done:

Finally, test your nginx installation:

$ /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.17.0

Run nginx service use this command:

$ sudo /usr/local/nginx/sbin/nginx

And then test it from the browser by accessing: http://your-ip-address

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.