Deploy  python django project using nginx, supervisor and gunicorn

Deploy python django project using nginx, supervisor and gunicorn

  • Post category:Django / Python

Step: 1) Installation Nginx, Supervisor in your Linux server (ex. Ubuntu, Red Hat Enterprise Linux (RHEL), SUSE, CentOS, or more)

$ sudo apt-get install nginx supervisor

Step: 2) copy your Django or any python project on the server

Step: 3) Create virtual environment and activate it

ubuntu@user:~/home/ubuntu/$ pip install virtualenv
ubuntu@user:~/home/ubuntu/$ cd myproject
ubuntu@user:~/home/ubuntu/myproject$ python -m virtualenv -p python3 venv
ubuntu@user:~/home/ubuntu/myproject$ source venv/bin/activate

Step: 4) Install gunicorn

ubuntu@user:~/home/ubuntu/$ pip install gunicorn

Step: 4) Test gunicorn is working

# For Django
ubuntu@user:~/home/ubuntu/$ gunicorn --bind localhost:7082 myproject.wsgi:application  

# For anathor python application
ubuntu@user:~/home/ubuntu/$ gunicorn --bind localhost:7082  main_app_variable.wsgi:application

sudo service supervisor restart