Python Django Tutorial: Deploying Your Application (Option #1) - Deploy to a Linux Server

Python Django Tutorial: Deploying Your Application (Option #1) – Deploy to a Linux Server

In this Python Django Tutorial, we will be learning how to deploy our application to a Linux Server from scratch using Linode.

If you would like $20 of free credit towards a Linode account, then you can use my link here to sign up:

We will be covering the entire deployment of a Django application. This includes spinning up a new Linux Server and tightening its security with SSH keys and firewalls. Then we will install Apache and Mod_WSGI so that we can get our Django App running. Let’s get started…

To skip the server setup, jump to 29:11

How to Run Linux/Bash on Windows:

SSH Key-Based Authentication Tutorial:

SSH Keys on Windows:

Apache config used in this video:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

#Python #Django

47 thoughts on “Python Django Tutorial: Deploying Your Application (Option #1) – Deploy to a Linux Server

  1. In this video, we set up a Linux server from scratch before we deploy Django, which is what a lot of people have requested. But if you already have a server ready to go then you might not be interested in the setup part. If you'd like to skip the Linux server setup and go straight to the deployment then please skip to 29:11

    Just be sure you make the code correction I mention at the 3:00 mark! Anyways, I hope people find this useful. Deployment can be a tricky topic because there are so many different choices (e.g. hosts, operating systems, web servers, etc). These are my preferred choices in this video. Remember, if you'd like to sign up for $20 of credit at Linode then you can use my link to signup:

  2. 30:30 If you followed the tutorial on a windows machine and can't run activate, you'll need to open the activate-file in Notepad++, go to Edit → EOL Conversion → Unix (LF) and then save. This converts it to a format that can be "sourced" in bash.

  3. I did all of my codings in Atom for this project and now I'm stuck (minute 30:13) not knowing how to setup virtual environment for the file i want to upload!! Can someone please tell me how I can get the virtual environment set up for atom?? :/

  4. Thank you so much for the video! I just wanted to add something.
    I don't know if others have encountered the same issue, but when i tried to install the requirements.txt, pillow couldn't be downloaded. After typing this in advance "sudo apt-get install libjpeg-dev" it worked. (I use Ubuntu 20.10)

  5. Hey Corey. I have heard that setting port for different than default 80, 8000 or 8080 for HTTP adds some more security. Do you agree with that? Does it make sense?

    The only reason for this that I have heard about is that there are bots strolling around the internet scanning those default ports for vurnerabilities.

  6. 1:10:00 Why you are showing a long way to debug? you can see the errors by simply going to error log of apache: sudo nano /var/log/apache2/error.log

    might be there is something that I can't understand but you can. that is why you are showing this. I will be very happy if you give me an answer. By the way, I'm a big fan of you

  7. If you guys want to see how to deploy django site to gcloud then you can check these tutorials…

  8. Hi, can you also make a video on how to deploy Django in a home mac for personal use? Is everything still the same in 2020?

  9. Thank you so much!…Can you please tell how to configure PostgreSQL on the same server and use it as database backend for django?…Should I just create a postgres user and database and change my to link my database backend to this database? Is it enough?

  10. Hi Thanks for This Knowledgeful Video. Every time i deploy django app i always go through this video once so that i do not miss anything at all. Again Thanks 🙂

  11. After deployment, I am not able to send email.
    It is saying 502 bad gateway
    Please anyone suggest,
    Any firewall settings?
    Allow port issues?

    Please suggest

  12. Thank you again for this top notch info. It's the best there is! Do you plan to make a tutorial about deployment using PythonAnywhere? I am looking forward to that.

  13. Thank you for the great series!! If I make some changes to my local project and I would like to have that changes on my server, would I have to just copy changed files to server and run migration and migrate on server?

  14. Hi. Great videos and learning path. I just started with Django and tried to rewrite some my Web to that. It looks more better and faster, but i stucked at one point. I have mySQL connection and im showing the data inside Bootstrap DataTable. It's working, but in the table bellow is small test -> counters for all rows and filtered rows. I'm not able to create correct ajax json structure to get it working. When im using just data, its ok. But with these counters not. Please could anyone help me with that or make a video about dataTables in Django ? I think it is used very often. Thanx a lot.

  15. fell asleep there from the django_project config file…phew, but managed to come back and go through till the end…Thanks for the video

  16. i keep getting this Forbidden

    You don't have permission to access this resource.

    Apache/2.4.29 (Ubuntu) Server at Port 80

    can you please advise ?

  17. Hi Corey, fantastic work. I have an issue. Though following your tutorial I created something else which is good and working with runserver. After I moved it to Apache2 watching this video, I am getting permission issues as in my application there are certain files and also some python scripts in project directory which some views use to execute and render results. I tried giving those python scripts and files a group ownership for www-data but no results. Could you please help on what am doing wrong or any additional config is required? one of the feature in app is under project directory i have script, from portal i take user input of file and in views am running subprocess.check_output to do the process , i get error , also have a text file which gets permission issues.

  18. This tutorial awesome!! I followed your tutorial it and hosted a django site on AWS here is my version guide to host django! Check it!

  19. Thanks again, Corey!
    All, I used this for a second time now – great resource. Just wanted to point out I'm using Python 3.8 and Ubuntu 20.04 and the latest Django package. I ran into a small problem with the mod_wsgi file – error: no django module found. I had to add sys.path.append('/home/myuser/MyappApp/')
    AND sys.path.append('/usr/local/lib/python3.8/dist-packages') to Basically the issue was that python has installed in the /usr/local path…. modified my .conf file in sites available to reflect the alternative python path. Hope this helps if anyone is having difficulty.

  20. I tried to find, but couldn't, why should we use Apache and not just run the server as is like python runserver and that's it? What are the benefits of using Apache?

  21. I am having the next error while trying to do runserver: TypeError: argument 1 must be str, not PosixPath, anyone got a clue how to fix it?

  22. Hey, great tutorial!

    You can use redial ( ) to copy ssh keys, list ssh connections, and much more

  23. Thank you very much! Before I deploy I want to add a few more things then will share the website. Are you going to make a video deploying on AWS or GCP too anytime?

  24. Corey I got stuck here for awhile on the deployment stage, I skipped this video to view the Heroku one instead and felt like I missed some things. I don't know, wasn't working right for me. Looked for some other quick fixes online and no one has anything relevant that I can find, lol. Hell with it, I'm gonna backtrack and use Linode, might as well learn this stuff at least once on my own. Thanks for being a great resource.

  25. I'm in the beginning of this video but guess that "kawrgs" around 4:00 might be the Bond villain of this episode.

Leave a Reply

Your email address will not be published. Required fields are marked *