Score:1

How to rename sites-available config file in Nginx?

bi flag

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.
dave_thompson_085 avatar
jp flag
In step 2 you removed the old name from sites-available, which was unnecessary because it already didn't exist after step 1, but you didn't remove the old name from sites-enabled. **Remove the old name from sites-enabled** -- i.e. remove the obsoleted _symlink_.
django_newbie avatar
bi flag
@dave_thompson_085, thanks! Deleted the old config and link from sites-available, restarted Nginx, created a new config, created new link, restarted Nginx again and it worked.
django_newbie avatar
bi flag
@dave_thompson_085, can you move the comment to an answer and I'll close the question?)
dave_thompson_085 avatar
jp flag
To me this is 'merely a typo' (although on checking I see that's a close reason on stackoverflow but not here), but if you think enough people would make the same mistake for this to add value in the future, it's okay to add your own answer (though you can't accept immediately); see https://serverfault.com/help/self-answer
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.