Setting up and using Akara on EC2
Contents
Start by setting up EC2. The Ubuntu EC2 Starter's Guide is an excellent intro. Just use this Jaunty alestic-64... ami-eef61587 AMI, which comes with Python 2.6.2, rather than the (older) Intrepid AMIs listed on that page. Once you have your EC2 instance booted up, proceed below:
Recipe 1: Amara+Akara+Moin Using the Sumo installer
This configuration recipe is for Akara+MoinMoin running on Amazon EC2 using the Jaunty 64bit AMI, but should work with any Jaunty set-up, including on a dedicated (non-cloud) server. It sets up a Moin instance:
available at http://myserver.example.com/mywiki
Wrapped by an Akara moinrest instance accessible at http://myserver.example.com:8880
Server basics and Apache
SSH into the server, using the appropriate SSH keypair (more info here)
- Update the OS:
aptitude update aptitude safe-upgrade
- Install Apache web server:
aptitude install apache2
Python and Moin
- Install Python development libraries and Python OpenID libraries:
aptitude install build-essential python2.6-dev aptitude python-openid
Install MoinMoin (latest is 1.8.2)
aptitude install python-moinmoin
- Change the data_dir value in /etc/moin/mywiki.py:
data_dir = '/usr/share/moin/data/'
Add the following to Apache config file /etc/apache2/sites-available/default (right before the line "ErrorLog /var/log/apache2/error.log":
### moin
ScriptAlias /mywiki "/usr/share/moin/server/moin.cgi"
alias /moin_static182 "/usr/share/moin/htdocs"
<Directory /usr/share/moin/htdocs>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
### end moin- Change ownership of moin directory to www-data:
cd /usr/share chown -R www-data moin chgrp -R www-data moin
- Modify /etc/moin/farmconfig.py to reflect correct directories (Critical setup section):
data_dir = '/usr/share/moin/data'
data_underlay_dir = '/usr/share/moin/underlay/'- Modify /etc/moin/farmconfig.py again to setup security (Security section):
# This is checked by some rather critical and potentially harmful actions,
# like despam or PackageInstaller action:
superuser = [u"JohnDoe", u"JaneDoe"]
# IMPORTANT: grant yourself admin rights! replace YourName with
# your user name. See HelpOnAccessControlLists for more help.
# All acl_rights_xxx options must use unicode [Unicode]
#acl_rights_before = u"YourName:read,write,delete,revert,admin"
acl_rights_default = u'Known:read,write'
acl_rights_before = u"JohnDoe:read,write,delete,revert,admin"
# Link spam protection for public wikis (uncomment to enable).
# Needs a reliable internet connection.
from MoinMoin.security.antispam import SecurityPolicy
from MoinMoin.auth.openidrp import OpenIDAuth
from MoinMoin.auth import MoinAuth
auth = [OpenIDAuth(),MoinAuth()]
anonymous_session_lifetime = 60- If applicable, move over any data from a previous wiki (data directory -- /usr/share/moin/data)
- Setup redirect for requests coming in to root of web server. Change /var/www/index.html to:
<META HTTP-EQUIV="Refresh" Content="0; URL=http://myserver.example.com/mywiki">
Akara ("sumo")
- Download, extract, and install the Akara software:
wget http://www.dabeaz.com/akara-sumo-2009-10-18-1537.tar.gz tar -xzf akara-sumo-2009-10-18-1537.tar.gz cd akara-sumo-2009-10-18-1537 python setup.py
- Install a couple demo Akara modules:
cp /root/akara-sumo-2009-10-18-1537/akara/demo/modules/xslt.py /root/.local/lib/akara/modules/modules cp /root/akara-sumo-2009-10-18-1537/akara/demo/modules/moinrest.py /root/.local/lib/akara/modules/modules
- Start the Akara server:
python -m "akara.server.run"
Recipe 2: Just Amara+Akara
This setup supports multiple akara users, in order to support multiple states of code and modules. Could also be done using virtualenv, but this is a bit more direct.
Server basics and Apache
SSH into the server, using the appropriate SSH keypair (more info here)
Update the OS:
aptitude update aptitude safe-upgrade
Python and daemon users
Install Python development libraries and other recommended packages site-wide
aptitude install build-essential python2.6-dev python-html5lib python-httplib2 python-dateutil
Set up akara users
#Just hit enter at all prompts adduser --disabled-password akara #another for production adduser --disabled-password akara-test #one daemon user for a set setup
Akara config per daemon user
Switch to each user in turn (e.g. su - akara-test). Create ~/.pydistutils.cfg with following contents:
[install] home = ~/.local
Install Amara from a nightly snapshot:
mkdir $HOME/dl; cd $HOME/dl wget http://files.akara.info/00-amara-latest.tar.bz2 mkdir $HOME/src; cd $HOME/src tar jxvf $HOME/dl/00-amara-latest.tar.bz2 cd amara python setup.py install
Install Akara from a nightly snapshot:
cd $HOME/dl wget http://files.akara.info/00-akara-latest.tar.bz2 cd $HOME/src tar jxvf $HOME/dl/00-akara-latest.tar.bz2 cd akara python setup.py install
Now prep the Akara config, as in Akara/Quick_start:
mkdir $HOME/.config/ mkdir -p $HOME/.local/lib/akara/logs mkdir -p $HOME/.local/lib/akara/modules cp lib/akara.conf $HOME/.config/ #Copy a module for testing cp demo/modules/echo.py $HOME/.local/lib/akara/modules
You may need to update PATH and PYTHONPATH, e.g. by adding the following to the ~/.profile (and running it on the command line for the first time)
export PATH=$PATH:~/.local/bin export PYTHONPATH=$PYTHONPATH:~/.local/lib/python
Start the Akara server:
akara start
If you get any errors, check the log at ~/.local/lib/akara/logs/error.log. You might need to tweak the config at ~/.local/.config/akara.conf
For sure you will want to make sure each akara daemon user is configured to use a different port (e.g. 8880, 8881, 8882, ...).
General tips
I found the default terminal settings a major pain, connecting from Mac Terminal, especially when using vi and such. Arrow keys were not working for cursor moving, etc. I expect this is an Ubuntu Jaunty issue, not EC2 in general. I added to my remote user environments
export TERM=ansi
(note: default seems to be TERM=xterm-color)
I also recommend doing
aptitude install vim
