Nginx on FreeBSD

2014-07-15 20:27

The purprose of this article is mostly to show how easy it is to compile and run custom builds of Nginx on FreeBSD, including third party modules which will be automatically fetched and built.

For a comprehensive list of compile time options and included modules for Debian and Ubuntu packages, check the following article: Nginx packages in Debian stable.

Installing Nginx via pkg:

pkg install nginx

By default, Nginx is compiled with the following options:

nginx version: nginx/1.6.0 TLS SNI support enabled configure arguments: --prefix = /usr/local/etc/nginx --with-cc-opt = '-I /usr/local/include' --with-ld-opt = '-L /usr/local/lib' --conf-path = /usr/local/etc/nginx/nginx.conf --sbin-path = /usr/local/sbin/nginx --pid-path = /var/run/nginx.pid --error-log-path = /var/log/nginx-error.log --user = www --group = www --with-ipv6 --http-client-body-temp-path = /var/tmp/nginx/client_body_temp --http-fastcgi-temp-path = /var/tmp/nginx/fastcgi_temp --http-proxy-temp-path = /var/tmp/nginx/proxy_temp --http-scgi-temp-path = /var/tmp/nginx/scgi_temp --http-uwsgi-temp-path = /var/tmp/nginx/uwsgi_temp --http-log-path = /var/log/nginx-access.log --with-http_stub_status_module --with-pcre --with-http_ssl_module

Installing Nginx using the ports collection:

cd /usr/ports/www/nginx make config

Below is a list of all available configuration options and third party modules, showing the Lua module highlighted and selected for compilation.

Once configured, we can launch installation and clean dependencies:

make install clean-depends

Starting Nginx:

After adding the nginx_enable directive in rc.conf :

echo 'nginx_enable="YES"' >> /etc/rc.conf

We can launch the server manually:

service nginx start

Nginx is now up and running and should be launched automatically at boot time.