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 extractThis 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 the pkg. Run the following command to upgrade the pkg:
cd /usr/ports/ports-mgmt/pkg
make reinstallOnce this has finished, you may run the following command to clean the directory of any temporary files:
make cleanSimilar 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-recursiveYou will get a configuration pop-up, and when you do, you 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.
make installOnce the installation is complete, you can run the following to clean up the directory from any files created by this step:
make cleanTo make nginx start on the 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.
In /etc/rc.conf add 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 startor
service nginx onestartUpon 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 /usr/local/etc/nginx/.
The default Nginx pages, such as Welcome to Nginx!, are located in /usr/local/www/nginx/.