You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this document, most of the lines in code sections can simply be copied and pasted into the terminal.
* virtualenv
* Django
* nginx
* uwsgi
Lines that follow each other immediately can generally be pasted in as one block. Lines separated by whitespace may require some user input between them, so should not be pasted as one block::
# these two lines can be copied
# and pasted as one block
# don't paste this one in the same block
Obtain Debian Linux
===================
Get a Debian network installer from http://www.debian.org (I used debian-6.0.5-amd64-netinst.iso).
Copy it onto a USB flash drive::
diskutil unmountDisk /dev/disk1 # unmount the volume
cat Desktop/debian-6.0.5-amd64-netinst.iso | dd of=/dev/disk1 :# copy the disk image
Boot up the machine from the flash drive, and let Debian use its suggested defaults.
When it comes to ask what software to install, tell it to install only:
* basic system utilities
* ssh server
Configure the system
====================
You'll need to login via ssh then su to root::
su root
Now you can login as from another machine instead of from the console. So do that now.
As root::
apt-get install sudo # now you can use sudo
adduser arkestra sudo # add your user account to the sudoers file
We don't need to be root anymore, so log out of root. You can't use sudo until you log in again though.
Login as arkestra::
sudo locale-gen en_GB.UTF-8 # set up locales
sudo /usr/sbin/update-locale LANG=en_GB.UTF-8
sudo apt-get update # shouldn't really be necessary, as this is a new install
sudo aptitude safe-upgrade
# installing handy things for compiling and building
Make your life easier: having /sbin on the path provides access to commands otherwise reserved for root::
pico ~/.profile # edit the user's profile
add::
PATH=$PATH:/sbin
export PATH
Log out then in again.
****************
ssh and firewall
****************
OpenSSH
Concept
=======
::
ssh-keygen # generate server keys # accept defaults & don't create a passphrase
Get your own public key(s) into and paste them into .ssh/authorized_keys::
# get your local key - not on the server, on your local machine!
less ~/.ssh/id_rsa.pub
On the server::
# edit the authorized_keys file on the server and paste them in
pico ~/.ssh/authorized_keys
nginx will face the outside world. It will serve media files (images, CSS, etc) directly from the file system. However, it can't talk directly to Django applications; it needs something that will run the application, feed it requests from the web, and return responses.
# make the permissions stricter
chmod 600 ~/.ssh/authorized_keys
That's uwsgi's job. uwsgi will create a Unix socket, and serve responses to nginx via the uwsgi protocol - the socket passes data in both directions::
Edit ssh_config::
the outside world <-> nginx <-> the socket <-> uwsgi
sudo pico /etc/ssh/sshd_config
Before you start
================
Change the following 3 options::
virtualenv
----------
Port 22
PermitRootLogin yes
PasswordAuthentication yes
Make sure you are in a virtualenv - you will install a system-wide uwsgi later.
to::
Django
------
Port 8888
PermitRootLogin no
PasswordAuthentication no
I am assuming Django 1.4. It automatically creates a wsgi module when you create a project. If you're using an earlier version, you will have to find a Django wsgi module for your project.
Note that I'm also assuming a Django 1.4 project structure, in which you see paths like::
The firewall
============
/path/to/your/project/project/
::
# install the Unix firewall
sudo apt-get install ufw
#open some ports
sudo ufw allow 8000/tcp # web dev
sudo ufw allow 8001/tcp # web dev
sudo ufw allow 8002/tcp # web dev
sudo ufw allow 8003/tcp # web dev
sudo ufw allow 8004/tcp # web dev
sudo ufw allow 8005/tcp # web dev
sudo ufw allow 8082/tcp # munin
sudo ufw allow 8888/tcp # for ssh
sudo ufw allow 80/tcp # standard http
sudo ufw allow 22/tcp # ssh
# enable the firewall
sudo ufw enable
# restart sshd
# make sure you do this as root, using sudo
sudo /etc/init.d/ssh restart
From now on you'll need to ssh on on port 8888.
************
MySQL server
************
::
# install mysql server and python interface
sudo apt-get install mysql-server python-mysqldb
Set a root password for MySQL.
::
sudo pico /etc/mysql/my.cnf # edit system-wide MySQL conf
Add (or if necessary change) in the [mysqld] section::
skip-character-set-client-handshake
collation_server = utf8_unicode_ci
character_set_server = utf8
::
sudo /etc/init.d/mysql restart
# test the server
mysql -u root -p # login
create database bongo; # create a database
show create database bongo; # see what's been created
You need to see that it's using the correct character set:
(i.e. it creates nested directories with the name of your project). Adjust the examples if you using an earlier Django.
`CREATE DATABASE 'bongo' /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci *`
It will also be helpful if you are in your Django project's directory. If you don't have one ready, just create a directory for now.
::
# drop the database
drop database bongo;
*****
nginx
*****
The version of Nginx from Debian stable is rather old. We'll install from backports::
sudo pico /etc/apt/sources.list # edit the sources list
Add::
# backports
deb http://backports.debian.org/debian-backports squeeze-backports main
About the domain and port
-------------------------
You must update aptitude's records::
I'll call your domain example.com. Substitute your own FQDN or IP address.
Throughout, I'm using port 8000. You can use whatever port you want of course, but I have chosen this one so it doesn't conflict with anything a web server might be doing already.
sudo /etc/init.d/nginx start # start nginx
Basic uwsgi intallation and configuration
=========================================
And now check that the server is serving by visiting it in a web browser. You'll get a "Welcome to nginx!" message.
Add www-data (default nginx user) to the arkestra group, so they can conveniently share folders::
sudo usermod -a -G arkestra www-data
**************
Other software
**************
Version control
===============
Install uwsgi
-------------
::
sudo apt-get install git mercurial # install Git and Mercurial
pip install uwsgi
Basic test
----------
Python
======
Create a file called test.py::
::
sudo apt-get install python-virtualenv python-dev # install virtualenv & development version of Python
It's necessary to keep an eye on the output of the installation procedure - sometimes a server hosting some dependency won't be available, so make sure there are no errors. If necessary, just run it again.
Install the right versions of Semantic Editor, Django Widgetry and Django Filer::
Point your browser at the server; if the site appears, it means uwsgi can serve your Django application from your virtualenv. Media/static files may not be served properly, but don't worry about that.
pip install -r src/arkestra/REQUIREMENTS.txt # install the things that pip can't do automatically
Now normally we won't have the browser speaking directly to uwsgi: nginx will be the go-between.
Basic nginx
===========
*********************
Test the example site
*********************
Install nginx
-------------
You can skip to *Set up a production server* if you don't need to test this.
The version of Nginx from Debian stable is rather old. We'll install from backports.
::
cd src/arkestra/example_14
python manage.py syncdb # answer "no"
sudo pico /etc/apt/sources.list # edit the sources list
server unix:///tmp/arkestra_example.sock; # a file socket
}
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name .example.com; # substitute the machine's IP address or FQDN
charset utf-8;
#Max upload size
client_max_body_size 75M;
# Django media
location /media {
alias /home/arkestra/arkestra/src/arkestra/example_14/example_14/media;
}
location /static {
alias /home/arkestra/arkestra/src/arkestra/example_14/example_14/static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
-----------------------------
Check that your nginx has installed a file at `/etc/nginx/uwsgi_params`. If not, copy http://projects.unbit.it/uwsgi/browser/nginx/uwsgi_params to your directory, because nginx will need it. Easiest way to get it::
Let's get nginx to speak to the hello world test.py application.
::
Set up the arkestra_medic database and user
-------------------------------------------
uwsgi --socket :8001 --wsgi-file test.py
You'll need a dump of the live database.
This is nearly the same as before, except now we are not using http between uwsgi and nginx, but the (much more efficient) uwsgi protocol, and we're doing it on port 8001. nginx meanwhile will pass what it finds on that port to port 8000. Visit:
Create the database, and import the dumped database file.
http://example.com:8000/
Create a MySQL user "<name of database user>" and give it all permissions for the database.
to check.
Set up the arkestra_medic project folder
----------------------------------------
Meanwhile, you can try to have a look at the uswgi output at:
The School of Medicine site (settings, templates, CSS etc) is on GitHub. It's publicly-available, and doesn't include:
http://example.com:8001/
* sensitive settings (passwords etc)
* Filer files (images, videos, etc)
but quite probably, it won't work because your browser speaks http, not uwsgi.
::
Using sockets instead of ports
==============================
# we'll install this in ~/
cd
It's better to use Unix sockets than ports - there's less overhead.
We can put the same options that we used with uwsgi into a file, and then ask uwsgi to run with that file::
Check that media files are being served correctly:
# django.ini file
[uwsgi]
* /media/media.png
# master
master = true
If this works, you'll know at least that nginx is serving files correctly.
# maximum number of processes
processes = 10
Create a file called arkestra_medic_uwsgi.ini in the project directory::
# the socket (use the full path to be safe)
socket = /tmp/uwsgi.sock
pico ~/arkestra_medic/arkestra_medic_uwsgi.ini
# with appropriate permissions - *may* be needed
# chmod-socket = 664
and put this in it::
# the base directory
chdir = /path/to/your/project
# django.ini file
[uwsgi]
# Django's wsgi file
module = project.wsgi
# master
master = true
# the virtualenv
home= /path/to/virtualenv
# maximum number of processes
processes= 10
# clear environment on exit
vacuum= true
# the socket (use the full path to be safe)
socket = /tmp/arkestra_medic.sock
# 666 is very permissive, but you can use this if necessary just for testing
# chmod-socket = 666
# the base directory
chdir = /home/arkestra/arkestra_medic
# Django's wsgi file
module = arkestra_medic.wsgi
And run uswgi using the file::
# the virtualenv
home = /home/arkestra/arkestra
uwsgi --ini django.ini
# clear environment on exit
vacuum = true
Note:
Deactivate your virtualenv::
--ini django.ini
use the specified .ini file
deactivate
Test emperor mode
=================
And run uswgi using the file::
uwsgi can run in 'emperor' mode. In this mode it keeps an eye on a directory of uwsgi config files, and spawns instances ('vassals') for each one it finds.
The last step is to make it all happen automatically at system startup time.
Just for now, because the current live server is old, we need to change a couple of items in the database - adjust contenttypes table and filer_video table
Edit /etc/rc.local and add::
* django_content_type id 212, change app_name from filer to video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this document, most of the lines in code sections can simply be copied and pasted into the terminal.
Concept
=======
Lines that follow each other immediately can generally be pasted in as one block. Lines separated by whitespace may require some user input between them, so should not be pasted as one block::
# these two lines can be copied
# and pasted as one block
# don't paste this one in the same block
Obtain Debian Linux
===================
Get a Debian network installer from http://www.debian.org (I used debian-6.0.5-amd64-netinst.iso).
Copy it onto a USB flash drive::
diskutil unmountDisk /dev/disk1 # unmount the volume
cat Desktop/debian-6.0.5-amd64-netinst.iso | dd of=/dev/disk1 :# copy the disk image
Boot up the machine from the flash drive, and let Debian use its suggested defaults.
When it comes to ask what software to install, tell it to install only:
nginx will face the outside world. It will serve media files (images, CSS, etc) directly from the file system. However, it can't talk directly to Django applications; it needs something that will run the application, feed it requests from the web, and return responses.
* basic system utilities
* ssh server
That's uwsgi's job. uwsgi will create a Unix socket, and serve responses to nginx via the uwsgi protocol - the socket passes data in both directions::
Configure the system
====================
the outside world <-> nginx <-> the socket <-> uwsgi
You'll need to login via ssh then su to root::
Before you start
================
su root
virtualenv
----------
Now you can login as from another machine instead of from the console. So do that now.
Make sure you are in a virtualenv - you will install a system-wide uwsgi later.
As root::
Django
------
apt-get install sudo # now you can use sudo
I am assuming Django 1.4. It automatically creates a wsgi module when you create a project. If you're using an earlier version, you will have to find a Django wsgi module for your project.
adduser arkestra sudo # add your user account to the sudoers file
Note that I'm also assuming a Django 1.4 project structure, in which you see paths like::
We don't need to be root anymore, so log out of root. You can't use sudo until you log in again though.
/path/to/your/project/project/
Login as arkestra::
(i.e. it creates nested directories with the name of your project). Adjust the examples if you using an earlier Django.
sudo locale-gen en_GB.UTF-8 # set up locales
sudo /usr/sbin/update-locale LANG=en_GB.UTF-8
It will also be helpful if you are in your Django project's directory. If you don't have one ready, just create a directory for now.
sudo apt-get update # shouldn't really be necessary, as this is a new install
sudo aptitude safe-upgrade
About the domain and port
-------------------------
# installing handy things for compiling and building
I'll call your domain example.com. Substitute your own FQDN or IP address.
Make your life easier: having /sbin on the path provides access to commands otherwise reserved for root::
Throughout, I'm using port 8000. You can use whatever port you want of course, but I have chosen this one so it doesn't conflict with anything a web server might be doing already.
pico ~/.profile # edit the user's profile
Basic uwsgi intallation and configuration
=========================================
add::
Install uwsgi
-------------
PATH=$PATH:/sbin
export PATH
Log out then in again.
****************
ssh and firewall
****************
OpenSSH
=======
::
pip install uwsgi
ssh-keygen # generate server keys # accept defaults & don't create a passphrase
Get your own public key(s) into and paste them into .ssh/authorized_keys::
# get your local key - not on the server, on your local machine!
less ~/.ssh/id_rsa.pub
On the server::
# edit the authorized_keys file on the server and paste them in
There is an alternative to using the `--module` option, by referring instead to the wsgi *file*::
And now check that the server is serving by visiting it in a web browser. You'll get a "Welcome to nginx!" message.
wsgi-file /path/to/your/project/project/wsgi.py
i.e. the system file path to the wsgi.py file
Add www-data (default nginx user) to the arkestra group, so they can conveniently share folders::
sudo usermod -a -G arkestra www-data
Point your browser at the server; if the site appears, it means uwsgi can serve your Django application from your virtualenv. Media/static files may not be served properly, but don't worry about that.
**************
Other software
**************
Now normally we won't have the browser speaking directly to uwsgi: nginx will be the go-between.
Version control
===============
::
Basic nginx
===========
sudo apt-get install git mercurial # install Git and Mercurial
Install nginx
-------------
The version of Nginx from Debian stable is rather old. We'll install from backports.
Python
======
::
sudo pico /etc/apt/sources.list # edit the sources list
sudo apt-get install python-virtualenv python-dev # install virtualenv & development version of Python
sudo apt-get install python-ldap # install ldap support
Video
=====
We install Handbrake and ffmpeg2theora::
sudo pico /etc/apt/sources.list # edit the sources list (because handbrake isn't otherwise available)
Add::
# backports
deb http://backports.debian.org/debian-backports squeeze-backports main
#Handbrake
deb http://www.debian-multimedia.org squeeze main # use this multmedia repository
Then::
sudo apt-get update
sudo apt-get install handbrake-cli ffmpeg2theora
Miscellaneous libraries
=======================
::
sudo apt-get install libxml2-dev libxslt-dev libjpeg8-dev # install some libraries
uwsgi
=====
Install uwsgi for the system::
sudo pip install uwsgi
Django & Arkestra
=================
::
cd # just make sure we're in ~/
virtualenv arkestra # the virtual environment that will contain all our Python software
It's necessary to keep an eye on the output of the installation procedure - sometimes a server hosting some dependency won't be available, so make sure there are no errors. If necessary, just run it again.
Install the right versions of Semantic Editor, Django Widgetry and Django Filer::
pip install -r src/arkestra/REQUIREMENTS.txt # install the things that pip can't do automatically
*********************
Test the example site
*********************
You can skip to *Set up a production server* if you don't need to test this.
And now check that the server is serving by visiting it in a web browser on port 80 - you should get a message from nginx: "Welcome to nginx!"
**************************
Set up a production server
**************************
Configure nginx for your site
-----------------------------
Check that your nginx has installed a file at `/etc/nginx/uwsgi_params`. If not, copy http://projects.unbit.it/uwsgi/browser/nginx/uwsgi_params to your directory, because nginx will need it. Easiest way to get it::
This is nearly the same as before, except now we are not using http between uwsgi and nginx, but the (much more efficient) uwsgi protocol, and we're doing it on port 8001. nginx meanwhile will pass what it finds on that port to port 8000. Visit:
# master
master = true
http://example.com:8000/
# maximum number of processes
processes = 10
to check.
# the socket (use the full path to be safe)
socket = /tmp/arkestra_example.sock
Meanwhile, you can try to have a look at the uswgi output at:
# 666 is very permissive, but this is just for testing
python manage.py runserver 0.0.0.0:8001 # 8001 because nginx may already be using 8000, if you tested it with the example project
Create a file called arkestra_medic_nginx.conf in the project directory::
And run uswgi using the file::
pico ~/arkestra_medic/arkestra_medic_nginx.conf
uwsgi --ini django.ini
and put this in it::
Note:
# nginx.conf
upstream arkestra_medic {
# connect to this socket
server unix:///tmp/arkestra_medic.sock; # a file socket
}
--ini django.ini
use the specified .ini file
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name .example.com; # substitute the machine's IP address or FQDN
charset utf-8;
Test emperor mode
=================
#Max upload size
client_max_body_size 75M;
uwsgi can run in 'emperor' mode. In this mode it keeps an eye on a directory of uwsgi config files, and spawns instances ('vassals') for each one it finds.
# Django media
location /media {
alias /home/arkestra/arkestra_medic/arkestra_medic/media;
}
Whenever a config file is amended, the emperor will automatically restart the vassal.
location /static {
alias /home/arkestra/arkestra_medic/arkestra_medic/static;
}
::
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass arkestra_medic;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
Symlink to this file from /etc/nginx/sites-enabled so nginx can see it::
Just for now, because the current live server is old, we need to change a couple of items in the database - adjust contenttypes table and filer_video table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -145,7 +145,7 @@ And now check that the server is serving by visiting it in a web browser on port
Configure nginx for your site
-----------------------------
Copy http://projects.unbit.it/uwsgi/browser/nginx/uwsgi_params to your directory. nginx will need this. Easiest way::
Check that your nginx has installed a file at `/etc/nginx/uwsgi_params`. If not, copy http://projects.unbit.it/uwsgi/browser/nginx/uwsgi_params to your directory, because nginx will need it. Easiest way to get it::
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is an alternative to using the `--module` option, by referring instead to the wsgi *file*::
wsgi-file /path/to/your/project/project/wsgi.py
i.e. the system file path to the wsgi.py file
Point your browser at the server; if the site appears, it means uwsgi can serve your Django application from your virtualenv. Media/static files may not be served properly, but don't worry about that.
Now normally we won't have the browser speaking directly to uwsgi: nginx will be the go-between.
superdmp
revised
this gist Jul 11, 2012.
1 changed file
with
1 addition
and
1 deletion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This should serve a hello world message directly to the browser on port 8000. Visit::
@@ -101,11 +101,11 @@ Now run it using uwsgi::
The options mean:
--chdir /path/to/your/project
chdir /path/to/your/project
use your Django project directory as a base
--module project.wsgi
module project.wsgi
i.e. /path/to/your/project/project/wsgi.py
--virtualenv /path/to/virtualenv
virtualenv /path/to/virtualenv
the virtualenv
Point your browser at the server; if the site appears, it means uwsgi can serve your Django application from your virtualenv. Media/static files may not be served properly, but don't worry about that.
@@ -336,13 +336,11 @@ Whenever a config file is amended, the emperor will automatically restart the va
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx will face the outside world. It will serve media files (images, CSS, etc) directly from the file system. However, it can't talk directly to Django applications; it needs something that will run the application, feed it requests from the web, and return responses.
That's uwsgi's job. uwsgi will create a Unix socket, and serve responses to nginx via the uwsgi protocol - the socket passes data in both directions::
the outside world <-> nginx <-> the socket <-> uwsgi
Before you start
================
virtualenv
----------
Make sure you are in a virtualenv - you will install a system-wide uwsgi later.
Django
------
I am assuming Django 1.4. It automatically creates a wsgi module when you create a project. If you're using an earlier version, you will have to find a Django wsgi module for your project.
Note that I'm also assuming a Django 1.4 project structure, in which you see paths like::
/path/to/your/project/project/
(i.e. it creates nested directories with the name of your project). Adjust the examples if you using an earlier example.
It will also be helpful if you are in your Django project's directory. If you don't have one ready, just create a directory for now.
About the domain and port
-------------------------
I'll call your domain example.com. Substitute your own FQDN or IP address.
Throughout, I'm using port 8000. You can use whatever port you want of course, but I have chosen this one so it doesn't conflict with anything a web server might be doing already.
Point your browser at the server; if the site appears, it means uwsgi can serve your Django application from your virtualenv. Media/static files may not be served properly, but don't worry about that.
Now normally we won't have the browser speaking directly to uwsgi: nginx will be the go-between.
Basic nginx
===========
Install nginx
-------------
The version of Nginx from Debian stable is rather old. We'll install from backports.
::
sudo pico /etc/apt/sources.list # edit the sources list
Add::
# backports
deb http://backports.debian.org/debian-backports squeeze-backports main
Check that media files are being served correctly:
Add an image called media.png to the /path/to/your/project/project/media directory
Visit
http://example.com:8000/media/media.png
If this works, you'll know at least that nginx is serving files correctly.
nginx and uwsgi and test.py
===========================
Let's get nginx to speak to the hello world test.py application.
::
uwsgi --socket :8001 --wsgi-file test.py
This is nearly the same as before, except now we are not using http between uwsgi and nginx, but the (much more efficient) uwsgi protocol, and we're doing it on port 8001. nginx meanwhile will pass what it finds on that port to port 8000. Visit:
http://example.com:8000/
to check.
Meanwhile, you can try to have a look at the uswgi output at:
http://example.com:8001/
but quite probably, it won't work because your browser speaks http, not uwsgi.
Using sockets instead of ports
==============================
It's better to use Unix sockets than ports - there's less overhead.
Now uwsgi and nginx should be serving up your Django application.
a uwsgi .ini file for our Django application
============================================
Deactivate your virtualenv::
deactivate
and install uwsgi system-wide::
sudo pip install uwsgi
We can put the same options that we used with uwsgi into a file, and then ask uwsgi to run with that file::
# django.ini file
[uwsgi]
# master
master = true
# maximum number of processes
processes = 10
# the socket (use the full path to be safe)
socket = /path/to/your/project/uwsgi.sock
# with appropriate permissions - *may* be needed
# chmod-socket = 664
# the base directory
chdir = /path/to/your/project
# Django's wsgi file
module = project.wsgi
# the virtualenv
home = /path/to/virtualenv
# clear environment on exit
vacuum = true
And run uswgi using the file::
uwsgi --ini django.ini
Note:
--ini django.ini
use the specified .ini file
Test emperor mode
=================
uwsgi can run in 'emperor' mode. In this mode it keeps an eye on a directory of uwsgi config files, and spawns instances ('vassals') for each one it finds.
Whenever a config file is amended, the emperor will automatically restart the vassal.
::
# symlink from the default config directory to your config file