Setting up Django + NGinx + Green Unicorn in an Ubuntu EC2 instance
adrian.org.ar
adrian.org.ar
This will get you up and running but just be aware that some of the items may not be the "correct way" of doing it.
As for SSL certs, don't you store those on the load balancer? If you are running a single box and it goes down, pointing the LB at a new backend box is a lot easier than copying certs around.
As for SSH keys, I'm not quite sure what damage could be done there. The only thing on there is public keys, right?
As I said below, this is a big reason why I believe in PaaS if your application can deal with it (and most can). Sysadmin has become so commoditized that there is no point in wasting your own time/money dealing with this stuff.
Not really. It seems everything runs from a virtual environment under the Ubuntu user which is not root btw.
I don't think so. Removing the templates directory gives you an exception. Maybe you are using another loader?
>>Also running nearly everything as root.
Right, this was meant for starters so I didn't want to complicate things. But I just added some options so now Upstart will run GUnicorn under other user.
1. You should use the nginx PPA instead of the default Ubuntu one.
2. uWSGI is an excellent alternative to Gunicorn, and can be run as a system startup service using supervisord.
3. As you get further along in your django project development, you may find you will need to apply patches to django core. In this case it helps to install from the git repo instead of pip, then checkout to the latest stable tag.
4. Instead of running `sudo /etc/init.d/nginx restart`, the idiomatic Ubuntu way is `sudo service nginx restart`.
"Look, here is our official release under nginx.org and there is some wonderful work from volunteers which you can install development, stable and nightly builds without hassle"
Noted
>2
I chose GUnicorn for being more popular and easier to install. Performance difference seems to be very small and not sure how things evolved in last versions.
>3
Certainly not what I want for an introduction.
the UWsgi module is also now included with NGinx by default (as of version .84 or something)
I've never used Upstart as in the original post but I believe Supervisor does the same thing and is maybe a little more commonly used (http://supervisord.org/)
http://nichol.as/benchmark-of-python-web-servers.
Setup is a bit more difficult, but if you are already using nginx it isn't so bad.
I have been using gunicorn+gevent in production for a while now and it has been outstanding.
We use http://gunicorn.org/ as our WSGI server;
we used to use mod_wsgi and Apache, but found
Gunicorn was much easier to configure, and less
CPU-intensive.
http://instagram-engineering.tumblr.com/post/13649370142/wha...I'd rather pay the 'extra' money to a PaaS in order to not have to a) hire a sysadmin, or pretend to be one on TV. b) get a full nights sleep. c) be able to go on vacation without worrying if the server is up or not. d) not have to worry about adding servers when my traffic has spiked and this one server isn't enough.
If you don't think EC2 instances go down, you are kidding yourself. Not only do they go down, but they 'appear' up. Talk about a mixed message. So, you also need to pay for a third party monitoring service just to tell you that your server is down.
At the end of the day, when you've added up all of those 'costs' of running your own servers, PaaS starts to look at lot more attractive. I certainly trust a company like Google AppEngine to be able to hire a lot more sysadmins, setup better monitoring and have better response times for fixing servers than I ever could.
I'd also love to never have to learn or remember the arcane list of setup configuration that this person blogged about. Instead, I'd rather be adding features to my app and making money.
IMHO, you shouldn't use a PaaS unless you know how to set your stack up. Essentially, if you don't recognize or have respect for the convenience you're being given (by going through a platform) then you'll potentially make bad decisions down the road. Personally, I prefer to learn how to set it up and scale it myself initially which helps me better understand what to look for in a platform.
Plus, there's something fun about putting all the pieces together and watching your apps come up (especially if you don't normally handle this part of the stack).
It's Turtles as a Service all the way down.
* Because i can understand the technology behind the "magic".
* Because i can understand the technology behind the "magic" and design my system better.
* Because i can understand the technology behind the "magic" and design my system better and if PaaS provider goes out of business i have a chance to survive.
* Like snap said before : i've got the power...
And most important : because i'm a masochist bastard, who has trust problems...
Also I don't think comfortable having all this uncontrolled "magic" happening.
EC2 is free for a year so I think it's worth giving it a shot.