background preloader

NGinx / Supervisor / Gunicorn

Facebook Twitter

Django Gunicorn and Nginx Setup. Posted by: Matt Mansour 2 years, 1 month ago (0 comments) After a hearing a great Gunicorn talk by Brian Riley of EdgeCast.com at the LADjango meetup I decided it was time to dive in to a modern server for Django.

Django Gunicorn and Nginx Setup

After getting around a few bumps I realized setting up Gunicorn with NGINX was easy. Even though I appreciate - and was blown away by - Graham Dumpleton's mod_wsgi for Apache, I feel it's time to push forward. I am glad I did and as a result, if I am unable to use Heroku on a project I will now most likely use NGINX, Gunicorn, and Postgres as the stack for some Django projects.

Gunicorn is a simple pip install. . $ virtualenv ~/envs/guni --no-site-packages $ cd ~/envs/guni/bin $ source activate (guni)$ pip install django (guni)$ pip install gunicorn (guni)$ cd ~/webapps (guni)$ django-admin startproject guni Now that we have Gunicorn and Django installed we create a simple shell script. (guni)$ cd guni Create a new file called guni.sh (guni)$ sudo vim guni.sh #!

*Note. And Likewise. Installation et test de NGinx sous Ubuntu. NGinx est une des alternative au serveur Web Apache (il est actuellement utilisé par plus de 6% des serveurs Web).

Installation et test de NGinx sous Ubuntu

Il se targue d'être plus rapide, plus léger et facile à configurer. Nous allons vérifier tout cela dans ce billet en détaillant une installation de NGinx 0.8.54 (Stable) sur une machine GNU/Linux (Ubuntu Desktop 10.10) avec en bonus le support FastCGI de PHP et de Perl ! On commence par ajouter le dépôt officiel pour la version stable: sudo add-apt-repository ppa:nginx/stablesudo aptitude update Puis on installe la bête (facile non ?) Sudo aptitude install nginx Remarque: si un serveur Web (Apache ou autre) tourne déjà sur votre machine, l'installation de NGinx se passera normalement, par contre il n'arrivera pas à se lancer car le port HTTP par défaut (TCP/80) sera déjà occupé.

Un script de démarrage nommé nginx a été installé dans le répertoire /etc/init.d. Sudo service nginxUsage: nginx {start|stop|restart|reload|force-reload|status|configtest} Puis lancer le serveur: #! Brent's Ramblings: HTTP Long Polling (aka Comet) with Nginx. Say you need to have live updates on your web site, like to receive chat messages.

Brent's Ramblings: HTTP Long Polling (aka Comet) with Nginx

In this article, I will explain how to use the HTTP push module for the Nginx web server for this. There are several other ways to do this, but most of them have serious drawbacks. Short Polling Probably the easiest to implement is simple polling - just fire off an AJAX request every 5, 10, or 15 seconds to an action on your server that simply checks for new messages, and if there are new messages they are sent as the response. Either send the data back as JSON and have Javascript on the client end take care of what to do with it, or send back Javascript instructions for what to do with the data. Client doesn't get real time updates. Web Sockets Maybe in 4 years this will be a real option, but right now (2011) it's not an option.

Long Poll (aka Comet) As A Controller Action Another pretty simple thing to set up is long polling. Server resources for open connections. Nginx Push Module for Long Polling.