Tuesday, April 3, 2012

Deploying tornad based Webapp on Centos with nginx,supervisor and Tornado in production




===========================================================================
Deploying Webapp on Centos with nginx,supervisor and Tornado in production
============================================================================


1 simple json =>
----------------------

#yum install python

#yum install python-setuptools

#easy_install simplejson



2 mysql=>
---------------

#yum install mysql

#yum install mysql-server

#/etc/init.d/mysqld restart

#mysqladmin -uroot password xyz

#mysql -u root -p

#password = xyz

mysql>create database alfred; ===> creating DB

mysql> source /yourpath/xxx.sql

mysql>source /root/apps/tornado-production-skeleton/ftech.org/db/webapp.sql   ==>importing DB of webapp

mysql> quit

The last method can be used with PHP, Python or Perl scripting mysql API.

login in mysql and type


3 python and then mysql development packges
-----------------------------------------------------------------

#yum install python-devel mysql-devel gcc wget python-setuptools

#curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv

#cd MySQL-python-1.2.3

or if feel lasy think smart

mkdir sam && cd sam && curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv


#python2.6 setup.py build  ==> to build

#python2.6 setup.py install ==> run setup.py

Note: python 2.6 or python setup.py build
         python 2.6 or python setup.py install

Note how I called the script explicitly using the following python binary: /usr/bin/python26

Now we’re good to give it the old test thus:

# python26 -c "import MySQLdb"


If it doesn’t spit out an error, you’re aces. Bazinga!


4 Tornado server =>
---------------------------
# wget http://github.com/downloads/facebook/tornado/tornado-2.1.1.tar.gz
# tar xvzf tornado-2.1.1.tar.gz
# cd tornado-2.1.1
# python setup.py build
# sudo python setup.py install

5 Installing pyhton_pip

# python-pip Install

# pip requires python-pip-0.8-1.el6.noarch.rpm or yum install python-pip


   1. Download the latest epel-release rpm from

      http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

   2. Install epel-release rpm:

      # rpm -Uvh epel-release*rpm

   3. Install python-pip rpm package:

      # yum install python-pip



6 mako =>
---------------

#  pip-python install Mako


7 date utils=>
-------------------

# wget ftp://rpmfind.net/linux/dag/redhat/el5/en/ppc/fabian/RPMS/python-dateutil-1.2-1.el5.rf.noarch.rpm

# rpm -Uvh python-dateutil-1.2-1.el5.rf.noarch.rpm


9 Install nginx =>
------------------------

# set hostname hostname ftech.org for eg

# hostname -f

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

# yum update

# yum install nginx

# /etc/init.d/nginx start

8 supervisord =>
-----------------------

# easy_install supervisor

# echo_supervisord_conf > /etc/supervisord.conf

change setting of config

# supervisord -c supervisord.conf


requirement for running webapp on port 8888 or user defined port

No comments:

Post a Comment