Deploying Django project on EC2 with BitNami image - python

I have a complex university project that requires building some specific libraries and the use of threads (AppEngine out of the question), and I want to deploy in on EC2 (Free tier deal).
I was wondering what would be best, to start with a bare linux distribution or the BitNami Django stack ?
I've seen similar questions here, but I'm looking for Pro's and Con's mainly.

The answer is pretty obvious. If you start with the Bitnami stack you'll save yourself the hassle of installing and configuring the various components (web server, gateway, python and the required libs, DB, etc.).
So if you app is pretty straight forward (typical web app) then sure, start with the bitnami stack. At most you'll reconfigure certain parts later on, as needed.
There's no particular joy in installing and configuring it all yourself, imo.

Related

Hosting multiple Django instances on a VPS

I'm moving away from WordPress and into bespoke Python apps.
I've settled on Django as my Python framework, my only problems at the moment are concerning hosting. My current shared hosting environment is great for WordPress (WHM on CloudLinux), but serving Django on Apache/cPanel appears to be hit and miss, although I haven't tried it as yet with my new hosting company. - who have Python enabled in cPanel.
What is the easiest way for me to set up a VPS to run a hosting environment for say, twenty websites? I develop everything in a virtualenv, but I have no experience in running Django in a production environment as yet. I would assume that venv isn't secure enough or has scalability issues? I've read some things about people using Docker to set up separate Django instances on a VPS, but I'm not sure whether they wrote their own management system.
It's my understanding that each instance Python/Django needs uWSGI and Nginx residing within that virtual container? I'm looking for a simple and robust solution to host 20 Django sites on a VPS - is there an out of the box solution? I'm also happy to develop one and set up a VPS if I'm pointed in the right direction.
Any wisdom would be gratefully accepted.
Andy :)
Traditional approach
Virtualenv is good enough and perfectly ready for production use. You can have multiple virtualenv for multiple projects on the same VM.
If you have multiple database engines for multiple projects. Like, MySQL for one, PostgreSQL for another something like this then you just need to set up each individually.
Install Nginx and configure each according to project.
Install supervisor to manage(restart/start/stop) each project individually.
Anything that required by the project.
Here it has a huge drawback. Because you can't use different versions on your database engine for a different project in an easy way. So, containerization is highly recommended.
For simple and robust solution,
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.
That's it.
I created a bash script that deploys as many websites as you want on your server. It automatically installs all dependencies on your server, creates a virtual environment, configure Gunicorn, Nginx, and a database for Django, etc. Check it out:
https://github.com/jdbit/django-auto-deploy

How to distribute Django web app to users?

I am developing a Django app to run on every client computer separately. The question is, which technologies should I use to distribute such as docker, virtual machine etc.? How can I protect the Django app's code? How can I prevent to distribute without licenses?
I suggest you look into Heroku. They have a free plan too so you can test it without having to pay first. Their guide with django after you set up an app is good too. You will find everything in their documentation but if you get stuck, I recommend this video by Corey Schafer. Good luck
Edit: Heroku also supports Docker but I'm not too familiar with it. Might be useful to you

How to deploy Django without mod_wsgi

I'm relatively new to web development, but I have a couple years experience working with python, so I figured I would build my first production site using django.
I've spent the last few days learning the basics and building a test site running on my local machine. Today, I've been trying to deploy my site to production; however, I've hit a pretty large stumbling block.
The django documentation suggests using mod_wsgi for apache deployments. I followed the install instructions here, only to realize that I don't have access to make any changes to apache - I'm currently on a shared hosting plan.
Apparently, to perform the install, I would have to upgrade to a VPS plan, which costs a lot more.
Any advice for a new web developer trying to get a proof-of-concept web app together (preferably with feedback gathered from real users) on a budget?
I think I have two options:
Eat the cost on my current web hosting plan. Try to find a cheaper host that specializes in django hosting. I've been looking at the following (suggestions here would be wonderful):
Heroku
DigitalOcean
A2Hosting
Try some sort of manual deployment. Is this possible or has anybody ever made this work? I can't seem to find any resources about this.
I was able to install django on my web server and my site just seems like a collection of files at this point. Can I simply move this directory tree to my site using an ftp? And handle the database migration manually?
Can I just run django on my web server via ssh instead of from my local machine? Essentially just rebuild my site in production? I know this isn't a smart idea with a normal production site, but as a proof of concept, I don't mind some downtime if my code is buggy.
Thanks!
If you are just starting Heroku is probably perfect for you. It's super easy to set up, you don't have to handle the server configuration yourself and it has a free tier to do some tests until you are ready to go.
If you are OK with doing some more advanced server/service configuration, you can use Google Cloud, Azure or AWS. This last one has a one year free tier. If you go this route, I suggest using gunicorn/uwsgi + nginx instead of Apache mod_wsgi.

Hosting my Django site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Hi I'm looking for some advice I currently own a resseller package with Heart internet as I host a few personal websites. However I'm currently learning Django (The python Framework) and want to be able to host my own server.
I have been setting up virtual servers to play around with. Anyway to have SSH access you have to send in and ask them to open it for you, in the meantime of asking them if it was possible to install Django / set up SSH access i was advised that i can't use Django unless i purchase a Virtual machine even though Python is intalled on the server.
Surley i can install Django onto my server if i have SSH access? Has anyone else has a similair issue? Or can anyone advise me on what to do.. The last thing i was to do is spend more money with them.
Thanks.
It sounds like you're describing a shared hosting situation where you have SSH access but the webserver is preconfigured for you. You cannot practically install and serve Django on that machine, because you will not have access to the Apache or other webserver configuration. You could theoretically serve Django from a port other than the typical HTTP port, but this would be extremely irregular and your hosting company would not appreciate it.
You can deploy Django on Heroku: https://devcenter.heroku.com/articles/django . It is free to deploy for extremely low-volume applications or for development; cost scales linearly with capacity above that.
You can also use Google App Engine with a slightly older version of Django. Either of these options have official support from the respective vendors and so they are much better ideas than trying to work around a restriction set by your hosting provider.
Finally, you could pay for a virtual machine, in which you would have full access to the webserver configuration and could serve anything you like. Virtual machines are available from any number of companies at a wide range of price points. You could also develop a Django application without hosting it anywhere but your local machine for starters, and worry about hosting after your application is functional.
AWS :
Free tier available
great support(but for technical help you got to pay)
can use platform (PAAS) BeanStalk
can customize architecture in case you get a dedicated instance
great community of support
Custom domain
great documentation
can SSH
Most popular
Heroku:(Django)
Free to some extent
Can use only POSTgresql in free plan
git must
Good support
easy to start
custom domain
Can use bash in production(Not SSH).. cannot make direct changes in production. This is what makes your App stable. Any change/update goes through git.
code maintenance - good (deployment through git heroku commands only)
use AWS S3 to store static files
Temporary files are removed perodically
Once you scale that they start to bill, it is really costly.
Since this is a PAAS, you have got what you have got. It takes lots of efforts to customize(to some extent) the architecture of the APP.
Google App Engine:( Flask/Django project.)
Free to some extent
very easy to start(hello world app)
custom domain
code maintenance - good (automatic deployment)
Support is not available
Pythonanywhere:
Free to some extent
No custom domain in free plan
easy to use
Good support
Webfaction:(Django)
Not free.. (I think (minimal plan) costs 10 $ per month on shared hosting. )
SSH available
custom domain
Architecture customization.
Good support
I have really good experiences with pythonanywhere.com. It's also free for really small projects.
For me it seems to be just perfect for experimenting with django. Here is a short story how I switched from Google App Engine to pythonanywhere.com: Django unchained - python in the cloud
I was doing the virtual server thing for a while - then entered Heroku. An extremely easy (and in some cases completely free) way to deploy my django application.
I started where you are,in a shared hosting environment trying to make django work. I then taught myself a lot of server admin and server setup things - thereby moving to a dedicated virtual server setup.
Alas making Django work with apache and on a Centos box can be a pain - But Heroku made it all better. Easy app deployment and scalability. Heroku is a cloud application deployment service - it's all the benefits of a virtual server without the setup. It doesn't actually install on your server
Check out these two articles
https://devcenter.heroku.com/articles/django
http://rdegges.com/devops-django-part-4-choosing-heroku (There are some more to this article but they are very lengthy)
I had a new django app up on the internet in half the time. There is lots of cost estimations involved, which is why I would dive deep into the second article and it's various parts.
You can host Django on Amazon EC2. If you take advantage of their free tier you can do so free for one year in a micro instance (618Mb RAM, 30Gb filesystem). You get full control of the machine, including SSH access. There are a number of freely available images that already bundle Django including the BitNami Django Amazon Machine Image which is also available for free (disclaimer: I am one of the BitNami developers)

Getting started with Django on Amazon Web Services [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm starting to migrate a few applications to Amazon Web Services. My applications are Python/Django apps, running over MySQL.
I plan on using EC2 and EBS for starters.
I'm looking for a few things:
A good step-by-step tutorial explaining how to deploy Django on AWS. I've looked around, but most tutorials are from 2 years ago, so I'm worried they're outdated.
I'm trying to understand, with which AMI should I start? I know there's a BitNami AMI that comes preconfigured with Django goodiness, but I've seen a lot of other sources say you should start with a basic (clean) linux box and install everything yourself. Why?
Are there any other important things I should be thinking about? I have very little sysadmining experience (the apps are currently on WebFaction), so I'm not sure what I should be thinking about.
A few extra points:
I plan on running several applications on the same EC2 instance, I assume that's possible?
I'm using virtualenv to separate between the various apps right now, I assume I can continue doing the same on the EC2 instance?
Thanks!
There is nothing "special" with EC2 here. It just provides bare (or generally preconfigured from custom AMI) system instance - you have access to whole virtualized system, so you can safely break things on your own. Think about it as a specific VPS.
You have to prepare deployment by yourself, which is not so difficult - just follow the documentation. I'd advice to run with basic linux distro and add needed stuff than to rely on some preconfigured image. As for you questions:
You need to do two things: setup your instance (accounts, needed software, other custom setup, so some linux administration guide should be handy) and prepare django app deployment (deploy python code, hook up to web server). For the latter, general deployment instructions for django can be applied here ( http://docs.djangoproject.com/en/dev/howto/deployment/ ).
Start with AMI with your favorite linux distro, and then add necessary software from it's repository.
Mount and use EBS as soon as possible for all your data. When rebooted, EC2 instance will wipe out all it's data, so be prepared for this. Do system snapshots to AMI to have quick recovery on failure.
Yes, you can deploy several applications on one instance, but mind that EC2 instance is virtualized (with quite high "virtualization tax" imo, especially for smaller instances), so you might run into general performance problems. Assume that you'd need migrate to bigger instance/multiple instances after some time.
Virtualenv should be your default deployment tool. Yes, you can use it here too.
You can follow the official documentation of setting up Amazon ec2 instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html
You should start with an AMI that you are familiar with. For example, if you use Ubuntu, you can just use one of the Ubuntu AMI in the recommended page. I didn't use the BitNami server and my Django site is deployed smoothly.
If you are using Apache server, just follow the instructions on the official Django doc:
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/
I tried quite a few blogs but as you said, they are outdated. Just use the official docs and it will save you a lot of time.
This repo is meant to address exactly this issue - provide a reference implementation for a basic django project that can be deployed onto AWS ElasticBeanstalk.
https://github.com/pushkarparanjpe/django-awsome
It has:
Static assets
DB back-end
django contrib Admin
Just configure your EBS env, clone the repo and deploy!

Categories