0

I am following this tutorial https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

I am deploying django/react app on digital ocean ubuntu, for this i have made one project and running whole app through django by creating build folder, everything is fine, i create build folder, run django server using python manage.py runserver 0.0.0.0:8000 and app loads perfectly, but when i run my server through gunicorn using command gunicorn –bind 0.0.0.0:8000 mobilehut.wsgi, server runs successfully but template doesn’t load means react frontend doesn’t load and i got blank page.

I have created a new user and then deployed, i am not using root. I can’t find what the problem is with gunicorn as its my first time. Can someone please suggest me what to check, is there is wsgi.py issue or some other like of nginx file.

Wsgi.py file:

import os

from django.core.wsgi import getwsgiapplication

os.environ.setdefault(‘DJANGOSETTINGSMODULE’, 'mobilehut.settings’)

application = getwsgiapplication()

Nginx file:

server {
listen 80 defaultserver;
listen [::]:80 default
server;
root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

}

I am deploying django/react app on digital ocean ubuntu, for this i have made one project and running whole app through django by creating build folder, everything is fine, i create build folder, run django server using python manage.py runserver 0.0.0.0:8000 and app loads perfectly, but when i run my server through gunicorn using command gunicorn –bind 0.0.0.0:8000 mobilehut.wsgi, server runs successfully but template doesn’t load means react front doesn’t load and i got blank page.

I have created a new user and then deployed, i am not using root. I can’t find what the problem is with gunicorn as its my first time. Can someone please suggest me what to check, is there is wsgi.py issue or some other like of nginx file.

wsgi.py:

import os

from django.core.wsgi import getwsgiapplication

os.environ.setdefault('DJANGOSETTINGSMODULE’, 'mobilehut.settings’)

application = getwsgiapplication()
Do we need to check this ? /etc/nginx/sites-enabled/default, in this i tried to access with new user -> root var/www/html , it shows permission denied , is that a issue

server {
listen 80 defaultserver;
listen [::]:80 default
server;
root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

}
kindly suggest some solution, my app runs fine with this python manage.py runserver 0.0.0.0:8000 , but not with gunicorn –bind 0.0.0.0:8000 server loads but blank white page.

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!