As per Wikipedia, Nginx is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server. It runs on FreeBSD too. Lets now see how to install Nginx on FreeBSD and to Configure it as a Webserver.
Now let us start off with the installation using the following command.
pkg install nginx
After installation, we would need to enable Nginx while booting. Append the following line in /etc/rc.conf
nginx_enable="YES"
The configuration file for Nginx is /usr/local/etc/nginx/nginx.conf. Now we can check whether the following lines are uncommented in the file, and change the values if needed.
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /usr/local/www/nginx; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/www/nginx-dist; } } }
Let us now check if the syntax in the configuration is correct by using the following command.
service nginx configtest
We can now upload our own files to the folder /usr/local/www/nginx and run our website in this setup.
Once we make any change, we can reload the configuration using the following command.
service nginx reload
We can now load our website in the browser using the following URL. Replace ‘ip-address’ using the server’s IP.
http://ip-address