How to run poweredsites in local

Here is the steps to run poweredsites project in a local ubuntu

Python2.6 ENV

Please run commands in this section to make sure all libs are ready:

# install git to sync tornado source code, and build tools etc
sudo apt-get install git-core gcc make build-essential

# python basic tools
sudo apt-get install python-setuptools python2.6-dev

# third party libs 
sudo apt-get install python-pycurl python-mysqldb

sudo easy_install -U pymongo markdown beautifulsoup
                webhelpers formencode routes decorator

# tornado
git clone git://github.com/facebook/tornado
# And go to tornado folder run
sudo python setup.py install

Database

  • Please refer to How to setup MySQL and How to setup MongoDB to setup MySQL and MongoDB

  • add database poweredsites and user:felinx password:felinx to mysql and mongodb,of course, you can use your username and password, then change the project configuration.

  • import the schema in the repository to your mysql (poweredsites/conf/schema.sql)

Modify local Hosts

Mapping some subdomains to local machine, you can add more for testing:

sudo nano /etc/hosts

#
# /etc/hosts
#
127.0.0.1       static.poweredsites.org
127.0.0.1       www.poweredsites.org    
127.0.0.1       sites.poweredsites.org
127.0.0.1       tornado.poweredsites.org
127.0.0.1       jquery.poweredsites.org    
127.0.0.1       poweredsites.org

Server

Proxy poweredsites.org requests to localhost:8888(Apache or Nginx as your wish) Here is a Nginx exmaple, please refer to How to setup Nginx to setup nginx. The default port 80 will be conflict with apache2 if you already install apache2. If so, stop your apache2 or change apache2 listened port to another one.

Project

Yes, I hardcode something :(, I will refine that later.

  • put a symbol link or copy poweredsites/poweredsites/poweredsites.conf to /mnt/ebs/conf/sites/poweredsites.conf

  • Sync project root to /mnt/ebs/sites/poweredsites, then the layout of those files will like below.

    /mnt/ebs/sites/poweredsites/bin
    /mnt/ebs/sites/poweredsites/conf
    /mnt/ebs/sites/poweredsites/poweredsites
    /mnt/ebs/sites/poweredsites/poweredsites/static
    /mnt/ebs/sites/poweredsites/poweredsites/app.py
    

Run the app:

# setup mongodb index at the first time
python /mnt/ebs/sites/poweredsites/poweredsites/app.py --setup_db=1

# Run this one in normal, or run the upper one always.
python /mnt/ebs/sites/poweredsites/poweredsites/app.py

# for short
cd /mnt/ebs/sites/poweredsites/poweredsites/
python app.py

Then the app will be run at port 8888, type http://poweredsites.org in your browser to play with it. Use CONTROL + C to Quit the app.

Well done, congratulations, Have fun!

Felinx Lee   August 14, 2010
Comments blog comments powered by Disqus