How to rename sites-available config file in Nginx?

Tried to rename sites-available config files from project-name to project-name.net but got an error.

OS: Ubuntu 18

What have I been doing…

1. Created a new config file:

sudo mv /etc/nginx/sites-available/project-name
/etc/nginx/sites-available/project-name.net

2. Deleted the old config file:

sudo rm /etc/nginx/sites-available/project-name

3. Enabled the config file by linking it to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/project-name.net
/etc/nginx/sites-enabled

4. Tested Nginx configuration for syntax errors:

sudo nginx -t

After this got an error:

nginx: [emerg] open() "/etc/nginx/sites-enabled/project-name" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed

5. Tried to restart Nginx:

sudo systemctl restart nginx

And next error:

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

Read more here: Source link