skip to Main Content

I ran through this manual: https://www.techrepublic.com/article/how-to-enable-ssl-on-nginx/

I’m Working on Ubuntu 18.04 with an nginx webserver
At the end I tried to restart nginx but the server was down.

I deleted all the files I created during the process and got the following error message:

2021/03/12 12:20:08 [emerg] 1767#1767: open() "/etc/nginx/sites-enabled/www.example.com" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62

The file still exists in /etc/nginx/sites-enables/www.example.com, but is empty.

If I need to provide more information just ask.

Thanks for your help!

3

Answers


  1. Chosen as BEST ANSWER

    The solution was to remove these two files:

    rm /etc/nginx/sites-available/www.example.com rm /etc/nginx/sites-enabled/www.example.com

    Thanks for your help!

    Clay


  2. In your config file /etc/nginx/nginx.conf on line 62, you are including another config file. There is probably something like:

    include /etc/nginx/sites-enabled/*;
    

    This line includes all config files in /etc/nginx/site-enabled/ directory.

    Look there, and you will find file http://www.example.com. This file is symbolic link referring to real file located at /etc/nginx/sites-available/www.example.com

    But real file most likely does not exists so it cannot be open by nginx process. Remove symlink referring to non existent file and you should be fine:

    rm /etc/nginx/sites-enabled/www.example.com
    

    Now start nginx.

    Login or Signup to reply.
  3. You have a typo in the path to config file:

    The file still exists in /etc/nginx/sites-enables/www.example.com, but
    is empty.

    But it should exists following the path mentioned in the nginx config:

    open() "/etc/nginx/sites-enabled/www.example.com" failed (2: No such
    file or directory) in /etc/nginx/nginx.conf:62

    You can fix this moving the config from sites-enables/www.example.com to sites-enabled/www.example.com.
    Also before you start nginx after altering config files it’s best to check the configs using nginx -t command (or nginx -t -c /path/to/config).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search