Deploying to OVH


Topics: Django webdev Linux Go back


I used to have this Django website hosted in pythonanywhere.com. That is a service where you only (mostly) do the website development. But you don’t manage the server or the software versions. 
<br> <br>
It was a good place to start at the time. It took some of the burden of learning a lot of Linux or networking. But that comes at a cost. It is a lot cheaper to rent a Virtual Machine from a cloud provider. In addition, hosting a website on a SaaS platform (like pythonanywhere) is not a “real-world” type of deployment.
<br> <br>
So, I finally took the time to move out of pythonanywhere. I installed everything from scratch on a virtual server that I now rent from OVHCloud. I started by setting up the server itself. OVH just gave me the IPv4 and IPv6 addresses of my VM, a password, and I chose Ubuntu as the OS. 
<br> <br>
To start with, the server was available to me with an older version of Ubuntu. I fist upgraded the software, then created users and groups. I also set up my SSH keys and firewalls.
<br> <br>
Then I installed MySQL and Nginx. I also set up a virtual environment, where I installed Gunicorn, Django, and a couple of dependencies. 
<br> <br>
Nginx is the webserver, Gunicorn is a WSGI app server, and Django is the web framework. MySQL is the backend (the database), but I’m not counting this as a layer to serve the web site. Nginx is a reverse proxy server and also serves the static and media files. (It can do many other things).
<br> <br>
The three layers (Django, Gunicorn and Nginx) need configuration. After I got that right, I also got an SSL/TLS certificate in order to make the website “production-ready” with HTTPS. For this, I used “Let’sEncrypt” and Certbot.

I used to have this Django website hosted in pythonanywhere.com. That is a service where you only (mostly) do the website development. But you don’t manage the server or the software versions.

It was a good place to start at the time. It took some of the burden of learning a lot of Linux or networking. But that comes at a cost. It is a lot cheaper to rent a Virtual Machine from a cloud provider. In addition, hosting a website on a SaaS platform (like pythonanywhere) is not a “real-world” type of deployment.

So, I finally took the time to move out of pythonanywhere. I installed everything from scratch on a virtual server that I now rent from OVHCloud. I started by setting up the server itself. OVH just gave me the IPv4 and IPv6 addresses of my VM, a password, and I chose Ubuntu as the OS.

To start with, the server was available to me with an older version of Ubuntu. I fist upgraded the software, then created users and groups. I also set up my SSH keys and firewalls.

Then I installed MySQL and Nginx. I also set up a virtual environment, where I installed Gunicorn, Django, and a couple of dependencies.

Nginx is the webserver, Gunicorn is a WSGI app server, and Django is the web framework. MySQL is the backend (the database), but I’m not counting this as a layer to serve the web site. Nginx is a reverse proxy server and also serves the static and media files. (It can do many other things).

The three layers (Django, Gunicorn and Nginx) need configuration. After I got that right, I also got an SSL/TLS certificate in order to make the website “production-ready” with HTTPS. For this, I used “Let’sEncrypt” and Certbot. Link to project