If you are using Nginx as your web server (i.e to host your web app or website) you may be wondering how to enable your site configuration. If you are like me, you got your start with Apache2 and were used to the simple a2ensite command. However, in Nginx it is a little bit different.
In an Nginx install, there is a single line that tells Nginx where site configurations are. The below command shows that any site configuration file in the sites-enabled folder will be used to direct a request when the web server (nginx) receives one.
How to List All of Your Site Configurations
In Nginx, all site configurations begin in the sites-available folder. All site configurations, active or not, sit here. We can view all of them with the below command.
This command will create a list of all site configurations with the sites-available folder.
How to Enable a Site Configuration
If there is a specific site you'd like to enable, you can do so by making a symbolic link from it to the sites-enabled folder. Using the below command will accomplish this (replace example with the name of your site configuration file).
ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/
Next you will need to restart Nginx to ensure that your changes take effect.
sudo systemctl restart nginx
If all went according to plan, your site configuration will have taken affect and you can now access your web app or website.
Should you have any trouble, send me a message and I'll do my best to help out.