#! /bin/bash
# Instrutions for flask setup from: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-16-04
# Required packages not included with DO base Ubuntu 16.04
sudo apt-get update
sudo apt-get install mysql-server nginx python-pip python-dev elasticsearch libmysqlclient-dev libssl-dev yui-compressor
# mysql setup
CREATE DATABASE glyph CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'glyph'@'%' IDENTIFIED BY 'glyph';
GRANT ALL ON glyph.* TO 'glyph'@'%';
exit;
# Import data
mysql -u glyph -p glyph < db_dumps/schema.sql
mysql -u glyph -p glyph < db_dumps/glyph_latest.sql
# Global PIP items:
sudo pip install virtualenv
# virtualenv items:
pip install gunicorn
pip install -R requirements.txt
- Ensure you have
gitandmod_wsgiinstalled on your box, install using yum if necessary - Install the Python
Virtualenvpackage using yum - Clone this repository:
git clone https://github.com/urschrei/CDP.git cdto the directory (it's probably calledCDP)- Create a new virtualenv called
venv, by executingvirtualenv venv - Activate it by executing
source venv/bin/activate - Install the required Python libraries by executing
pip install -r requirements.txt - Ensure that a MySQL database named
glyphexists. Username and password should both beglyph. See the section on Character Sets, below, for encoding and collation settings - Execute
fab build_dbto create the database structure and populate it. The db can also be populated by first importingdb_dumps/schema.sql, then importingdb_dumps/glyph_latest.sql - Open the
run.wsgifile in an editor, and modify the first line with the full path to theactivate_thisscript. For example, if you've cloned this repository into the/var/wwwdirectory, the full path would be/var/www/CDP/venv/bin/activate_this.py - See here for a sample Apache WSGI virtualhost
- Remember to reload Apache when you've created the new vhost.
- Install Vagrant and Virtualbox
- Clone this repository, and
cdinto it - Run
vagrant up. This will create a new virtual machine with all necessary packages - When it's completed, run
vagrant sshto access the VM - Run
fab build_dbto populate the database - Run
fab run_appto start the application in debug mode - Access the site on localhost:5000
- The site will run in production configuration on
10.11.12.15
Other fab commands:
fab shell: open an IPython shell with an imported app context and db instance. Queries can then be run like so:db.session.query(Cdp).join(Sign).filter(Sign.sign_ref == 'AK').all()
The database can be accessed via SSH (using e.g. Sequel Pro):
- The SSH host is 10.11.12.15
- The SSH user and password are
vagrant/vagrant - The MySQL user is
root, the password is blank
The application user/pass are glyph/glyph, and the db is glyph
The search functionality requires Elasticsearch, running on port 9200.
In order to generate the index before first use, run fab elasticsearch. Record changes and insertions should propagate to the index automatically, so long as the ORM is being used (i.e. in the normal course of things). The import script may also be run manually from a fab shell: %run utils/elastic.py
As we're using MySQL, please pay particular attention to your DB's character encoding and collation settings, if you're setting it up manually.
For encoding, utf8mb4 should be used.
For collation, utf8mb4_bin should be used. Binary collation is required in order to distinguish between e.g. S and Š.
This project has a DOI: 10.5281/zenodo.11647
Cite as:
Stephan Hügel (2014). Cuneiform Digital Palaeography Project (CDPP) v0.2. ZENODO.
10.5281/zenodo.11647
