Creation of a simple uWSGI site

_$: apt-get install python-pip python-dev
_$: pip install virtualenv

_$: cd /srv
_$: virtualenv uwsgi
_$: cd uwsgi
_$: . bin/activate
(uwsgi): pip install uwsgi
Successfully installed uwsgi
Cleaning up...
(uwsgi): mkdir mysite
(uwsgi): cd mysite
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"
(uwsgi): uwsgi --http :8080 --wsgi-file
*** Starting uWSGI 1.4.4 (64bit) on [Fri Jan 18 09:27:22 2013] ***
compiled with version: 4.4.5 on 17 January 2013 13:20:55
os: Linux-2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012
nodename: web-a
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /srv/uwsgi/mysite
detected binary path: /srv/uwsgi/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uWSGI http bound on :8080 fd 4
spawned uWSGI http 1 (pid: 2507)
uwsgi socket 0 bound to TCP address (port auto-assigned) fd 3
Python version: 2.6.6 (r266:84292, Dec 26 2010, 22:48:11)  [GCC 4.4.5]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1e863f0
your server socket listen backlog is limited to 100 connections
mapped 72392 bytes (70 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1e863f0 pid: 2506 (default app)
*** uWSGI is running in multiple interpreter mode ***

Go to and check the hello world web page we just created.

Use Ctrl + C to stop the uwsgi process.

uWSGI behind a web server

The uWSGI server will be listening at port 3000. The web server will be listening at port 8080.

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
upstream app_server {

server {
    listen 8080;
    location / {
        include uwsgi_params;
        uwsgi_pass app_server;
_$: /etc/init.d/nginx restart
_$: ln -s /etc/nginx/sites-available/nginx-uwsgi /etc/nginx/sites-enabled/
(uwsgi): uwsgi --socket :3000 --wsgi-file

Go to and check the hello world web page.

uWSGI server restart

(uwsgi_shell1)_$: uwsgi --socket :3000 --wsgi-file --pidfile /tmp/
(uwsgi_shell2)_$: uwsgi --reload /tmp/