Search This Blog

Install MyTardis on Ubuntu Linux 16.04

  1. Create a service user account for running MyTardis:
    useradd -m -d /opt/mytardis -s /bin/bash tardis
  2. Check out MyTardis from github:
    cd /opt
    sudo git clone -b master https://github.com/mytardis/mytardis.git
    sudo chown tardis:tardis /opt/mytardis
  3. Install required ubuntu packages:
    sudo bash /opt/mytardis/install-ubuntu-requirements.sh
  4. Setup virtualenv for tardis account:
    sudo su tardis
    source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
    mkvirtualenv --system-site-packages mytardis
    pip install -U pip
    echo "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh" >> ~/.bashrc
    echo "workon mytardis" >> ~/.bashrc
    source ~/.bashrc
  5. (As user 'tardis',) To work around this bleach bug, set html5lib version by adding line below to requirements.txt:
    html5lib==0.9999999
  6. remove billiard from requirements.txt or after installing the required packages, re-install celery package to downgrade billiard to 3.3.0.23. This is because the installed billiard 3.5.0.0 is installed and it causes celery failed to process any task. (Thread ResultHandler crashed: TypeError ...)
  7. (As user 'tardis',) Install required Python packages:
    cd /opt/mytardis
    pip install -U -r requirements.txt
  8. (As user 'tardis',) Initialize tardis/settings.py (as user 'tardis'):
    cd /opt/mytardis
    mv tardis/settings_changeme.py tardis/settings.py
    add the following lines:
    DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
    DATABASES['default']['NAME'] = 'tardis_db'
    
  9. (As user 'tardis',) Generate SECRET_KEY and save to tardis/settings.py:
    echo "SECRET_KEY='`python mytardis.py generate_secret_key`'" >> tardis/settings.py
    or to re-generate:
    python -c "import os; from random import choice; key_line = '%sSECRET_KEY=\"%s\"  # generated from build.sh\n' % ('from tardis.default_settings import * \n\n' if not os.path.isfile('tardis/settings.py') else '', ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789\\!@#$%^&*(-_=+)') for i in range(50)])); f=open('tardis/settings.py', 'a+'); f.write(key_line); f.close()"
  10. (As user 'tardis',) Initialize database:
    python mytardis.py migrate
  11. (As user 'tardis',) Create cache tables:
    python mytardis.py createcachetable default_cache
    python mytardis.py createcachetable celery_lock_cache
  12. (As user 'tardis',) Collect static files and save to static/ directory under /opt/mytardis:
    python mytardis.py collectstatic
  13. (As user 'tardis',) Create superuser (as user 'tardis'):
    python mytardis.py createsuperuser
  14. (As user 'tardis',) Create var/store directory:
    mkdir -p var/store
  15. (As user 'tardis',) Start mytardis server:
    python mytardis.py celeryd &
    python mytardis.py runserver 0.0.0.0:8000
    Note: 1) celeryd has to be started manually prior mytardis; 2) append 0.0.0.0:8000 to runserver command will make the server serve other hosts rather than only localhost:8000
  16. Supervisor can be installed to auto-start celeryd and webserver...