If this is from a fresh installation (and not a CustomISO), then you will likely need to install the port tree. Providing that you have one already, it can be updated by using the following command:
portsnap fetch extract
This may take a few minutes to download, but once it has finished, you will be able to move on to the next step.
To install the ports that were recently downloaded, you will need to upgrade
pkg. Run the following command to upgrade
cd /usr/ports/ports-mgmt/pkg make reinstall
Once this has finished, you may run the following command to clean the directory of any temporary files:
Similar to the previous step, you will need to run the following commands to configure, compile, and install Nginx.
cd /usr/ports/www/nginx make config-recursive
You will get a configuration pop up and when you do may want to choose the following:
HTTP_GZIP_STATIC, HTTP_SSL, HTTP_DAV_EXT. It may be desirable to enable other modules to be compiled with Nginx. Any of the next pop-ups can be left at the default. Now run the following commands to install Nginx.
Once the installation is complete, you can run the following to clean up the directory from any files created by this step:
To make nginx start on boot of your server, edit
/etc/rc.conf. You can edit this file by running
ee /etc/rc.conf. Alternatively, you could use
nano. Nano can be installed by running
pkg install nano.
nginx_enable="YES" to the end of the file. Once this is done, you may proceed to the next step.
To start nginx, you may run either:
service nginx start
service nginx onestart
Upon success. You should see output similar to the following format:
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 verify that Nginx is configured properly, you can navigate to your IP address in a web browser. Navigate to
http://0.0.0.0 (Change IP accordingly). Upon success, you will see the "Welcome to Nginx!" page.
Nginx can be further configured in
The default Nginx pages, such as "Welcome to Nginx!" are located in