skip to Main Content

my gorgeous friends on the internet.
I was doing something about Nginx for deploying my app made by Django, Postgresql, Gunicorn, Nginx, and DigitalOcean.
First of all, The project name in the Github gist is btre_project, but my app’s project name is pfc_calc. Considering the name dif, I created project folder by coping and pasting the line on the gist.

sudo nano /etc/nginx/sites-available/pfc_calc

And, copy the code and paste it into the file I just made.

server {
    listen 80;
    server_name 104.248.152.6;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/djangoadmin/pyapps/pfc_calc;
    }
    
    location /media/ {
        root /home/djangoadmin/pyapps/pfc_calc;    
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

BUT, here is where I made a mistake and got an error
I was so foolish that I forgot to change btre_project to pfc_calc

sudo ln -s /etc/nginx/sites-available/btre_project /etc/nginx/sites-enabled

Because I noticed that mistake, I typed this line again.

sudo ln -s /etc/nginx/sites-available/pfc_calc /etc/nginx/sites-enabled

I thought it would be ok and my mistake was under the bridge, but it wouldn’t.
When I typed this line

sudo nginx -t

this error below showed up.

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

I think I needed to delete the file I mis-created when I typed

sudo ln -s /etc/nginx/sites-available/btre_project /etc/nginx/sites-enabled

Any help??

Set up explanation and my terminal

2

Answers


  1. Chosen as BEST ANSWER

    Below is the continuous code in the terminal

    djangoadmin@ubuntu1:~/pyapps/pfc_calc$ sudo systemctl restart nginx
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    djangoadmin@ubuntu1:~/pyapps/pfc_calc$ systemctl status nginx.service
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Tue 2021-07-20 01:42:48 UTC; 26s ago
         Docs: man:nginx(8)
      Process: 9926 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=
      Process: 9928 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAI
     Main PID: 28967 (code=exited, status=0/SUCCESS)
     ^X
    

  2. I think the issue is because it cannot resolve the symlink to the first conf you specified. If you can remove the btre_project inside /etc/nginx/sites-enabled then you’re good to go.

    PS: I tested it on a fresh nginx install and was able to reproduce the exact error you have

    enter image description here

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