This guide will help you install the Nginx web server for the FreeBSD operating system. First you need to install or upgrade (if already installed) the ports tree using the following command:
portsnap fetch extract
It usually takes a few minutes to download, and after the download is complete, you will proceed to the next step, which will be described.
To install these ports that were recently downloaded, you need to update pgk by running the following command:
cd /usr/ports/ports-mgmt/pkg make reinstall
Then you can already run the command to clean the directory from all temporary files:
This command configures, compiles, and installs the Nginx web server
cd /usr/ports/www/nginx make config-recursive
You will get the configuration pop up, and when you can choose the following: HTTP_GZIP_STATIC, HTTP_SSL, HTTP_DAV_EXT. It may be desirable to include other modules for compiling with Nginx. Then, install Nginx
After the installation is complete, you will need to run the following to clear the directory of any files that will be created by this step:
To start nginx when your server boots up, edit /etc/rc.conf. You can edit this file by running ee /etc/rc.conf. Alternatively you can use nano. Nano can be installed by running pkg install nano
In /etc/rc.conf. you need to add nginx_enable = “YES” to the end of the file. Once this is done, you can proceed to the next step.
To start, enter the command:
service nginx start
If the launch was successful, you can see the output, which will be approximately the following:
Performing sanity check on nginx configuration: nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful Starting nginx.
To make sure Nginx is configured correctly, you can go to your IP address in a web browser. Go to http://0.0.0.0 (change the IP accordingly). If successful, you will see the “Welcome to Nginx!” Page