Freebsd 11.0 – NginX

A quick installation of NginX with a standard configuration. This is by no mean optimal. NginX is a lightweight web-server, which also could be used for loadbalancing, cache server, and it offers many nice features that could be used to provide different services.

Portsnap installation of NginX:
# Keep portsnap up to date before installing.
portsnap fetch update

#Enter the NginX portsnap folder.
cd /usr/ports/www/nginx

# Compilation config for NginX and the same for the required packages.
# Accept default settings unless you have read the manual and you are sure
# what modules to add to the build.
make config-recursive

# Install everything / also compiles all extra features selected and clean up
make install clean

# start nginx at boot
echo 'nginx_enable="YES"' >> /etc/rc.conf
Latest version just by compiling it on your own:
# Enter the tmp folder
cd /tmp

# Replace the x.y.z with the latest stable version
# First we have to install pcre, won't work with pcre2.
# (

# Un-tar the file
tar -zxf pcre-x.y.tar.gz

# Setup the conf for the compile

# Compile

# Install the files
make install

# Delete temp files
cd /tmp | rm -R /tmp/pcre-x.y/ | rm /tmp/pcre-x.y.tar.gz

# Download the latest version of Nginx Directly from the site (

# Un-tar the file
tar -zxf nginx-x.y.z.tar.gz

# Enter the folder
cd nginx-x.y.z

# Configure before the compile (options here:
./configure --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/var/run/ --with-cc-opt="-I /usr/local/include" --with-ld-opt="-L /usr/local/lib" --with-http_stub_status_module

# Compile

# Copy the files into the correct folder and so on.
make install

# Remove the un-needed files, this will auto delete if you have installed 
# freebsd 11.0 with the security option 'empty temp upon reboot'
cd /tmp | rm -R /tmp/nginx-x.y.z/ | rm /tmp/nginx-x.y.z.tar.gz

# Create this directory if it doesn't exist
mkdir /usr/local/etc/rc.d

#Download the nginx boot script and chmod it with +x
cd /usr/local/etc/rc.d | fetch --no-verify-peer | chmod +x /usr/local/etc/rc.d/nginx

#Adding NginX into rc.conf to get it to start upon boot.
echo 'nginx_enable="YES"' >> /etc/rc.conf
Files and hints
# Configuration files located in: /usr/local/etc/nginx/
# Bin: /usr/local/sbin/nginx
# Pid file: /var/run/
# Logs for debugging located in: /usr/local/nginx/logs

# Start, stop, restart, & checkconfiguration
/usr/local/etc/rc.d/nginx start
/usr/local/etc/rc.d/nginx stop
/usr/local/etc/rc.d/nginx restart
/usr/local/etc/rc.d/nginx checkconfig
Sources worth reading

Leave a Reply

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