Open file /etc/default/locale to add or change LC_ALL to the following
LC_ALL="en_US.UTF-8"
Then logout and login again.
Update aptitude
$ apt-get update
$ apt-get upgrade
Install necessary packages
$ apt-get install build-essential
Install Python
$ apt-get install python2.7-dev python-setuptools
$ easy_install pip
Install git
$ apt-get install git-core
Generate a new SSH key
$ ssh-keygen -t rsa -C "your_email@youremail.com"
Then add the key from ~/.ssh/id_rsa.pub to GitHub as a deployment key
Test the key by
$ ssh -T git@github.com
Install virtualenv
$ pip install virtualenv
- I don't like using virtualenvwrapper in production server because I want to isolate everything for the web under one directory (in this case, all Python libraries).
Install Postgresql Server and Python library
$ apt-get install postgresql python-psycopg2 libpq-dev
Create a new database and database's user
$ sudo -u postgres createdb [database_name]
$ sudo -u postgres createuser -SDRP [database_user_name]
Config pg_hba.conf file (you may need to change version number)
$ sudo vim /etc/postgresql/9.3/main/pg_hba.conf
Then add the following to pg_hba.conf file let database user authenticated using password
local [database_name] [database_user_name] md5
Reload Postgresql server
$ /etc/init.d/postgresql reload
Install nginx
$ apt-get install nginx
Install PCRE library (necessary for rewrite module, if you need it)
$ apt-get install libpcre3-dev
Install uWSGI
$ apt-get install uwsgi uwsgi-plugin-python
Example website is example.com
Create folders
$ mkdir -p /web/example.com/
$ cd /web/example.com/
$ mkdir logs public_html source
$ cd /web/example.com/source/
$ git clone git@github.com:[username]/[repository].git
Set owner to www-data
$ chown -R www-data:www-data /web
$ cd /web
$ virtualenv example.com
$ cd /etc/nginx/sites-available
$ vim example.com
Add the following configuration to the file
server {
listen 80;
server_name $hostname;
access_log /web/example.com/logs/access.log;
error_log /web/example.com/logs/error.log;
location / {
uwsgi_pass unix:///run/uwsgi/app/example.com/example.com.socket;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
location /static {
root /web/example.com/public_html/static/;
}
}
Then create a symlink
$ ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
Then you may need to delete default site
$ rm /etc/nginx/sites-enabled/default
$ vim /etc/uwsgi/apps-available/example.com.xml
Add the following configuration to the file
<uwsgi>
<plugin>python</plugin>
<vhost/>
<socket>/run/uwsgi/app/example.com/example.com.socket</socket>
<pythonpath>/web/example.com/source/example/</pythonpath>
<wsgi-file>/web/example.com/source/example/example/wsgi.py</wsgi-file>
<virtualenv>/web/example.com</virtualenv>
<logto>/web/example.com/logs/example.com.log</logto>
<master/>
<processes>4</processes>
<harakiri>60</harakiri>
<reload-mercy>8</reload-mercy>
<cpu-affinity>1</cpu-affinity>
<stats>/tmp/stats.socket</stats>
<max-requests>2000</max-requests>
<limit-as>512</limit-as>
<reload-on-as>256</reload-on-as>
<reload-on-rss>192</reload-on-rss>
<no-orphans/>
<vacuum/>
</uwsgi>
Then create a symlink
$ ln -s /etc/uwsgi/apps-available/example.com.xml /etc/uwsgi/apps-enabled/example.com.xml
$ service uwsgi restart
$ service nginx restart
Install dependencies
$ apt-get install libjpeg62-dev zlib1g-dev libfreetype6-dev liblcms1-dev
Install Pillow
$ pip install Pillow
Thanks a lot .i was stuck in installing the pillow in virtual environment but now i am sorted