nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
add-apt-repository ppa:uwsgi/release
apt-get install nginx uwsgi python-virtualenv
$ virtualenv examplesite $ cd examplesite/ $ . bin/activate
$ mkdir pkg && cd pkg/ $ wget 'http://projects.unbit.it/downloads/uwsgi-0.9.4.2.tar.gz' $ wget 'http://nginx.org/download/nginx-0.7.65.tar.gz'
sudo su - nginx=stable # use nginx=development for latest development version add-apt-repository ppa:nginx/$nginx apt-get update apt-get install nginx
sudo add-apt-repository ppa:uwsgi/release
sudo aptitude install git
sudo apt-get build-dep python-psycopg2
easy_install -i http://downloads.egenix.com/python/index/ucs4/ egenix-mx-base
#pip_requirement file pip install -r pip_requirement
BeautifulSoup==3.2.0Django==1.2.4PIL==1.1.7Pygments==1.4South==0.7.3akismet==0.2.0cmsplugin-gallery==0.1.7cmsplugin-lastfm==0.1.0cmsplugin-pygments==0.7.3cmsplugin-youtube==0.1.5-alpha-1distribute==0.6.10django-appmedia==1.0.1-e git://github.com/Fantomas42/django-blog-zinnia.git@2931d7f540f883b60a49842f84af099dc1d2c618#egg=django_blog_zinnia-0.7-py2.6-devdjango-classy-tags==0.3.0django-cms==2.1.0django-cms-jplayer==0.1.10django-grappelli==2.3.1django-inline-ordering==0.1.3django-tagging==0.3.1django-tinymce==1.5.1a1django-xmlrpc==0.1.3easy-thumbnails==1.0-alpha-15egenix-mx-base==3.1.2feedparser==5.0psycopg2==2.3.2pyparsing==1.5.5wsgiref==0.1.2
PIL
psycopg2
pygments
pyparsing
south
sudo aptitude install postgresql-8.4
# adduser databaseuser
# passwd databaseuser
sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
sudo passwd postgres
sudo nano /etc/postgresql/8.3/main/postgresql.conf
Change the line containing
data_directory = '/var/lib/postgresql/8.3/main'
to
data_directory = '/data/main'
Now change
#listen_addresses = 'localhost'
to
listen_addresses = '*'
and also change
#password_encryption = on
to
password_encryption = on
Save the file, then open the pg_hba.conf file so we can control who can access the server:
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres ident sameuser
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all 0.0.0.0/0 md5 # wide-open, you may want to make this more specific to your database
start sql server
#create sql user
sudo su postgres
psql
CREATE USER 'user';
CREATE DATABASE 'database';
template1=# CREATE USER tom WITH PASSWORD 'myPassword';
Type the following command (you need to type command highlighted with red color):template1=# CREATE DATABASE jerry;
Now grant all privileges on databasetemplate1=# GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
Type \q to quit:template1=# \q
$ psql template1
OR$ psql -d template1 -U postgres
#fixing the mptt problem with django-cms
remove ../bin/lib/python2.6/site-.../mptt
pip install -U django-cms
change db settings in settings.py
python manage.py syncdb --all
python manage.py migrate --fake
#test uwsgi process
sudo /usr/bin/uwsgi-python2.6 --processes 2 --home /home/ubuntu/%site --socket 127.0.0.1:4000 --chmod-socket --env DJANGO_SETTINGS_MODULE=%site.settings -w "django.core.handlers.wsgi:WSGIHandler()" --pythonpath /home/ubuntu/%virutalenvpath --daemonize /var/log/uwsgi.log
edit the /etc/nginx/sites-available with
location / {
uwsgi_pass django;
include uwsgi_params;
}
upstream django {
server unix:/var/run/uwsgi/uwsgi-python2.6/%site/socket;
}
replace %site with your site folder
the nginx site config files are in /etc/nginx/sites-available and ln -s to /etc/nginx/sites-enabled
In /etc/uwsgi/uwsgi-python2.6/ place your %site.ini file
home=/home/ubuntu/%virtualenvpath
processes=2
module=django.core.handlers.wsgi:WSGIHandler()
env=DJANGO_SETTINGS_MODULE=%sitepath.settings
pythonpath=/home/ubuntu/%virtualenvpath
#My path goes like /home/ubuntu/%virtualenvpath/%sitepath
sudo /etc/init.d/uwsgi-python2.6 restart
sudo /etc/init.d/nginx restart