Question

I'm having trouble setting up nginx with gunicorn and django for multiple websites

Posted October 30, 2016 2.5k views
NginxUbuntuDjangoConfiguration ManagementDeployment

So I followed this tutorial because part two tells how to do it for multiple websites and domains (http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/) and everything went smoothly till the end when I erase the default config for mine in sites-available and sites-enabled the restart nginx. When I navigate to my site I get a “site cant be reached” error. I created the link for new config to sites-enabled from sites-available. supervisorctl says its running my gunicorn start script when I check the status. What I notice though is that at no point is gunicorn.sock created in the run directory. Am I supposed to create that? I tried that but to no avail. Can someone help

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Did you restart nginx after linking from sotes-available to sites-enabled? What’s the nginx status after restart?

  • sudo systemctl restart nginx
  • sudo systemctl status nginx

You should see a lot of informations but somewhere will be status.

You can verify your nginx configuration and see is everything okay:

  • sudo nginx -t
  • I restarted nginx and nginx test returns that everything is ok. the status command returns this:

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    devin@app-station:/run$ sudo service nginx status
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: e
    

    Active: active (running) since Mon 2016-10-31 01:51:08 UTC; 49s ago
    Process: 29289 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5
    Process: 29265 ExecReload=/usr/sbin/nginx -g daemon on; masterprocess on; -s
    Process: 29297 ExecStart=/usr/sbin/nginx -g daemon on; master
    process on; (co
    Process: 29294 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; masterproces
    Main PID: 29301 (nginx)
    Tasks: 2
    Memory: 1.7M
    CPU: 21ms
    CGroup: /system.slice/nginx.service
    ├─29301 nginx: master process /usr/sbin/nginx -g daemon on; master
    p
    └─29302 nginx: worker process

    Oct 31 01:51:08 app-station systemd[1]: Starting A high performance web server 
    Oct 31 01:51:08 app-station systemd[1]: nginx.service: Failed to read PID from 
    Oct 31 01:51:08 app-station systemd[1]: Started A high performance web server a
    
Submit an Answer