Skip to content

DeployingWithApache

Alex Rudnick edited this page May 29, 2014 · 14 revisions

HOWTO install your Guampa on Apache with WSGI.

These instructions should get you up and running with an installation of Guampa on your Linux server with Apache. Here we assume Ubuntu 14.04, although more recent releases should work as well, and other Linux distributions will be similar.

Packages you'll need...

At least on Ubuntu 14.04...

python3
python-pip
python-virtualenv
apache2
libapache2-mod-wsgi-py3
java7-jdk

check out an instance of Guampa

  • git clone https://github.com/hltdi/guampa.git

Note!! You should probably check out your copy of guampa somewhere underneath /var/www, so you don't have to change much about the Apache default security model. Let's call it /var/www/guampa.

This will be easier if your user has write access to the /var/www folder.

set up the virtualenv in your checkout

you@host:/var/www/guampa $ scripts/setup_virtualenv

virtualenv lets us keep all of the dependencies for Guampa (or any other Python project) in one place. It's incredibly convenient!

turn on your virtualenv

you@host:/var/www/guampa $ source venv/bin/activate

set up the database for your guampa instance

you@host:/var/www/guampa $ scripts/create_db.sh

OPTIONAL STEP! import some documents

You can skip this step and just use the web interface to upload documents.

Either use the Wikipedia import scripts, or import with: you@host:/var/www/guampa $ scripts/store_document.sh documents/sample.txt you@host:/var/www/guampa $ scripts/tag_document.sh 1 "example tag"

configure Apache to point at your app.wsgi

Effectively, do something like this: http://flask.pocoo.org/docs/deploying/mod_wsgi/#configuring-apache

Specifically...

  • Turn on mod_rewrite: sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

  • Add something like this to your site config file (which might be named /etc/apache2/sites-enabled/000-default):

      RewriteEngine  on
      RewriteRule    ^/guampa-demo$  /guampa-demo/  [R]
      WSGIDaemonProcess guampa-demo user=www-data group=www-data processes=1 threads=5
      WSGIScriptAlias /guampa-demo /var/www/guampa/app.wsgi
      <Directory /var/www/guampa>
      	WSGIProcessGroup guampa-demo
      	WSGIApplicationGroup %{GLOBAL}
      	WSGIScriptReloading On
      	Order allow,deny
      	Allow from all
      </Directory>
    
  • Restart apache2 (you may have to do this later, or a few times) sudo /etc/init.d/apache2 restart

Avoiding encoding problems

Make sure your Apache, in its /etc/apache2/envvars, does not set the LANG environment variable to "C". It should be something like "en_US.UTF-8", which is the default locale on our Ubuntu machine. A LANG of "C" will screw up document upload.

So in /etc/apache2/envvars, comment out that line that says "export LANG=C".

Uncomment where it it says:

# . /etc/default/locale

Make NLTK work

Again in /etc/apache2/envvars, add a line like this:

export NLTK_DATA=/home/YOURUSERNAMEHERE/nltk_data

(the setup_virtualenv script should have downloaded some files and put them in that nltk_data directory)

make the web server has the right permissions to write to the database file

The www-data will need to have rights to write not just to the guampa.db file, but also to the but also to the directory that contains guampa.db.

$ sudo chgrp www-data /var/www/guampa/guampa.db
$ sudo chgrp www-data /var/www/guampa
$ sudo chmod g+rw /var/www/guampa
$ sudo chmod g+rw /var/www/guampa/guampa.db

Clone this wiki locally