Skip to content

Server Setup of PhoneLab on Amazon Linux AMI

taeyeon edited this page Jul 12, 2012 · 7 revisions

PhoneLab Server is a Django Powered app to help manage PhoneLab Testbed project.

Dev Stuff

sudo yum install mysql mysql-devel mysql-server python-devel gcc

Start MySQL Service

Remember: This is required so that we can install the MySQL-Python Bindings. service mysqld start

Install MySQL-Python Bindings

Download from Here

Note: Once MySQL-Python Bindings are successfully installed, you can remove MySQL Server

Install PIP

curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python

Install South to migrate schema and data for Django

sudo easy_install South

Set up Env Vars

Open Bash Profile

vi ~/.bash_profile

Add the following line

export ENV=production

Reload bash_profile in current shell

source ~/.bash_profile

App Deployment: Fabric

Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. [http://fabfile.org]

Install Fabric

sudo pip install fabric

Using Fabric to Deploy PhoneLab Server App

fab production deploy or fab staging deploy

see fabfile.py for details

App Management: Gunicorn

Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy. [http://gunicorn.org/]

Install gunicorn

sudo pip install gunicorn

Add Gunicorn to Django APP

INSTALLED_APPS += ("gunicorn",)

Webserver: Nginx Configuration

Nginx acts as our reverse proxy webserver.

Install Nginx

sudo yum install nginx

To Start

sudo service nginx start

To Stop

sudo service nginx stop

To Restart

sudo service nginx restart

Editing Nginx.conf [Refer docs/nginx/nginx.conf]

sudo vi /etc/nginx/nginx.conf

Phonelab App as Service

Install the init.sh file into /etc/init.d [Refer docs/init.sh] sudo chmod +x phonelab sudo chkconfig phonelab --add

To Run App

To Start

/etc/init.d/phonelab start

To Stop

/etc/init.d/phonelab stop

To Restart

/etc/init.d/phonelab restart