| DJC | Django | Production Deployment |

Nginx and Gunicorn Configuration for Django - DJC

Installation

  • Make sure both Gunicorn and Nginx are installed on your server.

Gunicorn Configuration

  • Run Gunicorn pointing to your project’s WSGI file:
gunicorn --bind 0.0.0.0:8000 project_name.wsgi:application

Nginx Configuration

  • Create a server block in your Nginx configuration:
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /path/to/your/project;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/path/to/your/project/project_name.sock;
    }
}
  • Make sure to create a symbolic link in sites-enabled and restart Nginx to apply the changes.

| DJC | Django | Production Deployment |