Домой United States USA — software Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04

Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04

353
0
ПОДЕЛИТЬСЯ

How to install Django using a PostgreSQL database and then install and configure Gunicorn to serve applications using Nginx as a reverse proxy.
Join the DZone community and get the full member experience. Django is an open-source Python framework that can be used for deploying Python applications. It comes with a development server to test your Python code in the local system. If you want to deploy a Python application on the production environment then you will need a powerful and more secure web server. In this case, you can use Gunicorn as a WSGI HTTP server and Nginx as a proxy server to serve your application securely with robust performance. First, you will need to install Nginx and other Python dependencies on your server. You can install all the packages with the following command: Once all the packages are installed, start the Nginx service and enable it to start at system reboot: Next, you will need to install the PostgreSQL server on your server. You can install it with the following command: After the installation, log in to PostgreSQL shell with the following command: Next, create a database and user for Django with the following command: Next, grant some required roles with the following command: Next, exit from the PostgreSQL shell using the following command: \qexit Next, you will need to create a Python virtual environment for the Django project. First, upgrade the PIP package to the latest version: Next, install the virtualenv package using the following command: Next, create a directory for the Django project using the command below: Next, change the directory to django_project and create a Django virtual environment: Next, activate the Django virtual environment: Next, install the Django, Gunicorn, and other packages with the following command: Next, run the following command to create a Django project: Next, edit the settings.

Continue reading...