Building FOAM

Building FOAM on CentOS 6.2

FOAM is written in python, requires Python 2.6.x, NGINX (an http server) and a number of Python packages.

Install initial prerequisites

$ sudo yum install nginx 
$ sudo easy_install pip

Download the source code and build (you have to use Mercurial client - downloading a zip file from github will not set the version properly, so getVersion will return garbage):

$ hg clone https://bitbucket.org/onlab/foam
$ cd onlab-foam-xxxx
$ sudo python install.py 

If dependency tracking by pip fails as part of FOAM install, can be installed manually:

$ sudo easy_install "Flask==0.7.2"
$ sudo easy_install "SQLAlchemy==0.7.4"
$ sudo easy_install Flask-XML-RPC
$ sudo easy_install "Blinker==1.1"
$ sudo easu_install lxml
#ElementTree 1.2.7 has to be installed from source
#unzip, then sudo python setup.py install
#
#Flup can be installed by easy_install via egg

Continuing after foam install (note: installs under /opt/foam).

FOAM install fails to install M2Crypto, could not get it from EPEL and easy_install fails due to differences in openssl-devel configuration so get the source, untar and run ./fedora_setup.py install from within the tar file:

$ chmod +x fedora_setup.py
$ ./fedora_setup.py install

Change the permissions on the /opt/foam///. Note that FOAM uses www-data user under Debian (which is what nginx runs under) however on CentOS nginx runs under user nginx:

$ sudo chown -R nginx /opt/foam

Configure foam (Note that foamctl is installed under /usr/bin)

$sudo -u nginx foamctl init-db
$ sudo foamctl set-password

Create a self-signed cert for foam and configure /etc/nginx/sites-available/foam.conf (the default install.py fails to do that). Note that nginx under CentOS does not use sites-available/, instead using conf.d:

$ sudo vi /etc/nginx/sites-available/foam.conf
$ cd /etc/nginx/conf
$ sudo ln -s ../sites-available/foam.conf

Download and bundle certs

$ sudo wget http://www.pgeni.gpolab.bbn.com/ca-cert/pgeni.gpolab.bbn.com.pem -O /opt/foam/etc/gcf-ca-certs/pgeni.gpolab.bbn.com.pem
$ sudo foamctl bundle-certs

Start NGINX

$ /etc/init.d/nginx restart

Start FOAM (needs a custom start script because CentOS does not have start-stop-daemon which can put foam in the background; default centos daemon() function does not have the background option). The CentOS foam start script is attached to this page.

$ /etc/init.d/foam start

Attachments