Install Nginx on FreeBSD, OpenBSD and macOS
| FreeBSD | |
| OpenBSD | |
| macOS with Homebrew | |
| Build from source on any Unix | |
| Where your Nginx keeps its files |
Nginx was written for Unix systems, and the BSDs and macOS package it like any other program. Each system puts the files in its own places, so after the install the last chapter shows how to ask Nginx where they are.
The source build at the end was run on 26 October 2026 with the stable version 1.30.6. On Linux use the distribution packages instead: Install Nginx on Linux.
FreeBSD
On FreeBSD install the binary package as root:
pkg install nginx
FreeBSD starts no service until it is enabled in /etc/rc.conf. sysrc writes the line for you:
sysrc nginx_enable=YES
service nginx start
The configuration is in /usr/local/etc/nginx/, like everything a package adds to FreeBSD, and the default site serves /usr/local/www/nginx. After a change:
service nginx configtest
service nginx reload
The port www/nginx builds Nginx with other modules if the package lacks one you need.
OpenBSD
OpenBSD has its own web server, httpd, in the base system; Nginx is a package. Install it as root:
pkg_add nginx
If pkg_add lists several flavors, choose the plain one. Enable and start the service:
rcctl enable nginx
rcctl start nginx
The configuration is /etc/nginx/nginx.conf. OpenBSD packages that need setup steps install a short guide; read it before you put a site online:
/usr/local/share/doc/pkg-readmes/nginx
After a change test and reload:
nginx -t
rcctl reload nginx
macOS with Homebrew
On macOS Nginx comes from Homebrew:
brew install nginx
Start it now and at every login:
brew services start nginx
Homebrew sets port 8080 in its configuration, so Nginx runs without root rights:
curl -I http://localhost:8080/
The files are under the Homebrew prefix: /opt/homebrew on Apple silicon, /usr/local on Intel Macs.
| What | Path |
|---|---|
| Configuration | $(brew --prefix)/etc/nginx/nginx.conf |
| Your sites, one file each | $(brew --prefix)/etc/nginx/servers/ |
| Web root | $(brew --prefix)/var/www |
After a change test and reload:
nginx -t
nginx -s reload
brew info nginx prints these paths for your Mac, and brew services stop nginx stops Nginx and removes it from the login start.
Build from source on any Unix
The source works on every Unix-like system and gives the newest version with exactly the modules you choose. You need a C compiler, make, and the development files of PCRE2 (regular expressions in location), zlib (gzip) and OpenSSL (HTTPS). On Debian these are the packages build-essential libpcre2-dev zlib1g-dev libssl-dev.
Download the archive of the stable version from nginx.org/en/download.html and unpack it:
curl -O https://nginx.org/download/nginx-1.30.6.tar.gz
tar xzf nginx-1.30.6.tar.gz
cd nginx-1.30.6
HTTPS is not in the default build; add it:
./configure --with-http_ssl_module
The end of the output is the summary: which libraries were found and where Nginx will live:
Configuration summary + using system PCRE2 library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
Build and install:
make
sudo make install
Everything is in one folder, /usr/local/nginx, with the subfolders conf, html, logs and sbin. Check the result:
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.30.6 built by gcc 14.2.0 (Debian 14.2.0-19) built with OpenSSL 3.5.7 9 Jun 2026 TLS SNI support enabled configure arguments: --with-http_ssl_module
Start it with sudo /usr/local/nginx/sbin/nginx and control it with -s stop, -s quit and -s reload. A source build installs no service file and gets no security updates from the package manager: you rebuild it for every new version.
Where your Nginx keeps its files
Every build records its paths. nginx -V prints them as --conf-path, --error-log-path and --http-log-path, unless they are the defaults under --prefix. To see the whole configuration Nginx really reads, with all included files:
nginx -T
The configuration itself is explained in nginx.conf: configuration and sites.
Article author: Klavdiya Kondakova
| Install Nginx | |
| Install Nginx on Linux | |
| Install Nginx on Debian | |
| Install Nginx on Ubuntu | |
| Install Nginx on Windows | |
| Nginx |