981 B
981 B
Adding a new site to Nginx in Ubuntu
This guide assumes you already have Nginx running on your server.
Add an available site configuration
Create a new configuration file in the /etc/nginx/sites-available
directory. The file will usually be titled after the domain or subdomain you are adding
sudo vim /etc/nginx/sites-available/example.com
For the file contents enter a valid nginx server block configuration. Here is an example:
server {
listen 80;
server_name example.com www.example.com;
}
Add the site configuration
Once the configuration file is setup we can enable it by creating a symbolic link to the sites-enabled
directory.
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Test and Update Nginx
Test the configuration file for syntax errors:
sudo nginx -t
If the test is successful, reload Nginx to apply the changes:
sudo systemctl reload nginx