Hosting Django on a VPS

Hi Folks!

I’ve been learning Django for the past couple of years and I’m now ready to implement it as a backend solution. For someone who has always worked on the front end it’s a fabulous framework - especially for sole traders like myself.

The one issue I’m finding with Django is hosting. My shared hosting is all CloudLinux with WHM running cPanel instances. My current hosting providers doesn’t support Python with cPanel and this appears to be across the board with Australian hosting providers. My only real alternative now as I move away from WordPress is to create my own hosting solution, which also creates another income stream.

The advice that I have been given on StackOverflow is thus:

  • Use Docker(docker-compose) for local and production deployment.
  • Configure uWsgi with Nginx(Available on docker.)
  • Create a CI/CD pipeline with any tool like Jenkins.
  • Monitor your projects using any good tool like Raygun.

Can anyone point me to some good video tutorials (I’m a visual learner) in configuring a VPS for multiple domains? I’m hosting 17 sites on a reseller WHM account at the moment and I would like to rebuild half of them using Django to get my experience up before I go to market.

Thanks so much for any assistance.

Andy

Hello @StudioProjects. Configure a WHM its all through GUI, configure a VPS for Django will be almost entirely CLI. Do you have experience with Ubuntu/Debian or Fedora/Centos, or similar?

In order to help you with your request, you need to provide more background.

What OS, web server do you plan to use?

For what you are trying to do you need:

  1. have a VPS
  2. Install a Web server like Apache or Nginx
  3. If you want to install

HI Rigo!

Thanks so much for taking the time to answer.

My apologies for the vagueness of the question, I’ll try to clarify my situation.

I would be looking at a CloudLinux unmanaged VPS in Australia – possibly DreamIT.

Command line isn’t intimidating, I was a network engineer at one time and worked in a NOC.

The web server would be NginX in conjunction with uWsgi and containerisation with venv or docker.

I haven’t decided whether to use mySQL or mongoDB for the database…

My work is agency microsites in particular, along with small business websites and e-brochures.

Ostensibly I’m after a cheap way of hosting numerous websites on my own server.

Digital Ocean and AWS are prohibitively expensive for sole traders and small businesses.

There’s no specialised Python hosting in Australia and no decent hosts that support Python in cPanel…

Therein lies my dilemma!

:blush:

Andy Taylor

www.studioprojects.com.au

0424 656 973

Ok.
I have never used CloudLinux, but I think you will be able to make an equivalent deployment following the next tutorial:
How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04

When you complete your first deployment you can replicate the same procedure, but with new names in order to deploy other sites. For example your gunicorn.socket and gunicorn.service could be renamed as: gunicorn_b.socket and gunicorn_b.service severally (that is create new files, no rename the files you have used for your first deployment). The same for your venvs, nginx configurations files, etc.

Now, if you use environment variables in your Django project (highly recommended) be sure to include a file and a configuration line for that in gunicorn files.

Finally if you want to use https(highly recommended too) in your sites you can use Certbot, again there is no instruction for CloudLinux.

Now I am curious. Why use CloudLinux? I think this make senses for reselling WP and in general PHP hosting, but as far as I know there won´t be major benefit for Django deployment.

Hi Rigo!

Thanks for your wonderful help!

I will most certainly be using environment variables.

I’m happy to use Ubuntu, I’ve played around with it and it’s obviously very robust.

I think DreamIT put CloudLinux on their VPS, but I haven’t confirmed that.

Either way, I can put whatever I want on it so I’ll stick with Ubuntu.

Thanks again, mate :blush:

Andy Taylor

www.studioprojects.com.au

0424 656 973