Setting Up a Cloud Virtual Machine
If you’re looking for documentation for your cloud provider, then check out:
00:00 Cloud Environment and Django Setup.
00:05 In this course, you’ll use Django as the framework at the core of your web app, using it for URL routing, HTML rendering, authentication, administration, and back-end logic. Later on, you’ll supplement the Django component with two other layers, Gunicorn and Nginx, in order to serve the application scalably.
00:24 But before all of that, you’ll need to set up your environment and get the Django application itself up and running. First, you’ll need to launch and set up a virtual machine, or VM, on which the web application will run.
00:37 You should familiarize yourself with at least one infrastructure as a service (IaaS) cloud service provider to provision a VM. This section will walk you through the process at a high level but won’t cover every step in detail.
00:49 Using a VM to serve a web app is an example of IaaS, where you have full control over the server software. Other options besides this do exist, such as a serverless architecture, which allows you to compose the Django app only and let a separate framework or cloud provider handle the infrastructure side, or a containerized approach, which allows multiple apps to run independently on the same host operating system. For this course, though, you’ll use the tried-and-true route of serving Nginx and Django directly on IaaS. Two popular options for virtual machines are Azure VMs and Amazon EC2.
01:31 To get more help with launching the instance, you should refer to the documentation for your cloud provider. For Azure VMs, follow their quickstart guide for creating a Linux virtual machine in the Azure portal. For Amazon EC2, learn how to get set up.
01:51 The Django project and everything else involved in this course sit on a t2.micro Amazon EC2 instance running Ubuntu Server 22.04. Regardless of platform, one important component of VM setup is inbound security rules.
02:08 These are fine-grained rules that control the inbound traffic to your instance. Create the inbound rules seen on-screen for initial development, which you’ll modify in production.
02:20 The first rule allows TCP over port 8000 from your personal computer’s IPv4 address, allowing you to send requests to your Django app when you serve it in development on port 8000.
02:32 The second rule allows inbound traffic from network interfaces and instances that are assigned to the same security group, using the security group ID as the source.
02:42 This is a rule included in the default AWS security group that you should tie to your instance. The third rule allows you to access your VM via SSH from your personal computer.
02:56 You’ll also want to add an outbound rule to allow outbound traffic to do things such as install packages.
03:04 From your local computer, you will then be able to SSH into the instance.
03:15
This command logs you in to your VM as the user ubuntu
. Here, the first part of the command (~/.ssh/<privkey>.pem
) is the path to the private key.
03:23 This is part of the security credentials that you tied to the VM. This provides a much more secure method of access than using a username and password.
03:36 With this part of the setup complete, in the next section of the course, you’ll take a look at creating a basic Django app and some setup techniques that are useful when running a site on a cloud server.
Become a Member to join the conversation.