How to Deploy Scalable Django Apps Using Gunicorn and NGINX | Code with Harry
Deploying Django apps is a crucial step in the development process. In this article, we will discuss how to deploy scalable Django apps using Gunicorn and NGINX.
Step 1: Install Gunicorn
To start, you will need to install Gunicorn, a WSGI server for Python web applications. You can install Gunicorn using pip:
pip install gunicorn
Step 2: Run Gunicorn
To run your Django app using Gunicorn, navigate to your project directory and run the following command:
gunicorn --bind 0.0.0.0:8000 myproject.wsgi
Step 3: Install NGINX
Next, you will need to install NGINX, a high-performance web server and reverse proxy. You can install NGINX using apt-get:
sudo apt-get install nginx
Step 4: Configure NGINX
After installing NGINX, you will need to configure it to reverse proxy requests to Gunicorn. Create a new NGINX configuration file in the /etc/nginx/sites-available
directory with the following content:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
After creating the configuration file, activate it by creating a symbolic link to the /etc/nginx/sites-enabled
directory:
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
Step 5: Restart NGINX
Finally, restart NGINX to apply the changes:
sudo service nginx restart
Your Django app should now be deployed and accessible at your server’s IP address or domain name. Congratulations on successfully deploying your scalable Django app using Gunicorn and NGINX!
👍 harry sir
The video title is wrong, your title is Django Apps Using "uWSGI" and NGINX not "Gunicorn"
Tu b
New. Ringtone
How can I deploy kivy app in exe or apk I have already tried it using Collab and pyinstaller but these methods produces errors
English language samj me nahi aa rahi 😂
You was born to Code..
You was born to Serve
Love from Pakistan ❤️
You are a great teacher and guider to me✨🥺
Thanks! This was really helpful and informative!❤