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

preview_player
Показать описание
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

✅ 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:

#Python #Django
Рекомендации по теме
Комментарии
Автор

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

coreyms
Автор

By adding this video to your Django course. You had made this course "the best course on Internet". Coz. Nobody talk about this

shivamkumraa
Автор

Just being honest, this is the best Django deployment tutorial on the internet!

RisyadHasbullah
Автор

Your tutorials have made me the best web app developer in my area[East Africa Tanzania-Shinyanga]. Am a banker and I was learning as a hobby and made some few apps from skills I gained from you, suddenly some friends are asking me to create apps for their projects. Now I can design app from scrach to deployment with confidence. Thank you very much. Karibu Tanzania.

amanye
Автор

You're incredible.
As soon as you said "Set up ssh" I was thinking to myself how great it is that he is going through ALL the steps that should be taken and then you explain just that.

ljalmanzar
Автор

Timestamps:


02:33 – Fixing the bug from previous video
04:17 – Creating Linode
08:05 – Ip Address and SSH Credentials
10:13 – Root Connection to the Server
11:09 – Installing Software Updates
12:10 – Setting Host Name
12:46 – Setting Host File
13:59 – Adding Limited User
16:27 – Setting Up SSH Key Based Authentication
22:45 – Setting Permissions for SSH Directory
25:00 – Forbiding Root Login & Password Authentication
26:43 – Setting Up a Firewall
29:10 – Putting Django Application on Webserver
30:15 – Generating requirements.txt File
32:41 – Copying Django Application on to the Webserver
34:46 – Creating Virtual Environment on the Server
36:52 – Installing Dependencies
37:49 – Changing Django Settings for Testing the Application on Django Server
39:51 – Collecting Static Files
40:23 – Testing Application
44:30 – Installing Apache & ModWSGI
46:04 – Configuring Apache Webserver
54:38 – Enabling Site Through Apache
55:29 – Setting Up File Permissions
58:47 – Creating Configuration File for Hiding Sensitive Information
1:02:43 – Updating Project Settings File
1:07:01 – Allowing http Traffic
1:07:40 – Restarting the Server & Running the Site
1:08:57 – Fixing Final Bugs


Thank you for such a clean explanation.

Автор

1:08:04 - if you are getting an error, you probably have a syntax error or one of your folder has a space in it.
First check for the error. To do that type -
cd /etc/apache2
apache2ctl configtest
This will tell u about the error.

Now go back to your config file and wherever you r using a path with folder name with spaces just put it inside quotes like this -
"home/username/My\ Website/" <- My Website is a folder name with spaces

I hope this helps 😁🙌

shubhpatni
Автор

This is an amazing series of lessons, still completely relevant in late 2022 with the latest versions of Django and Python. I've learnt a lot. Many thanks for sharing these, Corey!

hrs
Автор

Most tutorial won't cover about deploy web application to the server but this tutorial really step up from the rest of YT videos.

trapenoone
Автор

Hey guys, so I faced a bunch of issues and wanted to share my experience on how to fix those. I saw some comments already mention this but I didn't see them at the time so I figured I might not be the only one in that situation.

First I faced a 403 issue, which was fixed by changing the file permission of the user directory with below command:
sudo chmod 711 /home/YOUR_USERNAME

After that, I could access the website but links and forms were broken: loading forever with no logs from django.
So I checked the logs in /var/log/apache2/error.log (if you don't have access, you can use that command: sudo cat /var/log/apache2/error.log)
It mentioned I had an issue with wsgi: "Truncated or oversized response headers received from daemon process"
The solution I found that worked and fixed everything is to add below line at the very bottom of the apache conf file - located at /etc/apache2/apache2.conf
WSGIApplicationGroup %{GLOBAL}

Here you go, hope that helps :)

mymrgoodkat
Автор

Your tutorial is golden. I encountered a few issues along the way, but still, without your guidance, I would be lost in the woods. Lessons learned (Ubuntu 18 server):
* Command: namei --modes /path/to/file is your friend when you look for permission errors
* Apache likes to have everything set as executable along the path
* Never place your venv outside user folder and do not mix sudo with pip install
* To trace errors in production, instead of setting debug=True, use Sentry.io

nfiu
Автор

Thank you, this was a fantastic tutorial. Deploying to production was one of my main concerns with learning Django. I'd love to see a video on migrating to MySQL or a Postgres database.

dcleveng
Автор

As a senior developer with a few years of experience in python, but being new to Django, I was having a lot of difficulty getting my Apache server connected to Django on my local Linux VM. This video cleared up all of my basic problems that I had already spent a solid 8 hours struggling with (that's a really long time for me). Your style and depth of explanation really exhibits your level of expertise with the tools in your tutorials.


Thank you very much for this.


Now all I have to do is struggle bus through implementing HTTPS...

gricklegrass
Автор

After following all your tutorials on creating a web app successfully I was lost without your help to deploy until now.. you are a lifesaver mate, I found deployment the hardest thing since I started learning python / django ! Thank you so much.

raphaelpz
Автор

33:50 copying files over // 44:42 installing wsgi and apache2 // 54:47 enable site apache // 13:35 hostname django-server

soffer
Автор

// Setting up a new server
set hostname 12:10
add user 14:20
permissions ssh 23:00
disable root login and password authentication 25:20
firewall 27:00

deployment 29:11

SimpleLangSolution
Автор

awesome series.... past 3 days I was looking to add dynamic website functionality... finally exploring all the options ... I wanted Python... and this has given me so much insight... I have watched all your 17 videos in one day... Simply superb!!!

abhinavbhardwaj
Автор

You actually trained me how strong django is
❤️💭💚 Thanks from INDIA

hadoopwithcp
Автор

The best thing that could ever happen to me is to wake up and see new video uploaded by you. You are the best teacher on YouTube.

bowenwang
Автор

First of all, thank you Corey for this great work!
For someone who faced issue to up your project after done setup the Apache2 and WSGI. My personal experience is don't put your project folder and venv folder under the /home directory. Besides, you also need to add WSGIApplicationGroup %{GLOBAL} to the bottom of the apache2 file which located at /etc/apache2/apache2.conf if you hit an error stated that "Truncated or oversize response header received."

hongweisoo