.. _aws:

Installing on Amazon Web Services
=================================

To make it easier for you to get an OppiaMobile server up and running, we have 
created an `Amazon Web Services <http://aws.amazon.com/>`_ machine image that 
you can copy and comes pre-packaged with the latest version of the OppiaMobile 
Server so will run 'out of the box'.


Launch an AWS Machine Image
------------------------------
Once you have created your account on AWS:

* Go into your instances page
* Select 'launch instance'
* Select 'Community AMIs'
* Search for 'oppia' and you should see the most recent version of the 
  OppiaMobile AMI listed
* Launch your new instance - you can alter the instance configuration (security 
  groups etc) during the rest of the launch instance process.
  
.. note::
	When you search the OppiaMobile server AMI will only appear in the search 
	results if you have selected the 'EU (Ireland)' zone

Once your instance is up and running you will be able to assign a static IP, 
access via your web browser and log into the server using SSH. It is beyond the 
scope of this guide to give the full information about how to connect and 
configure your AWS account instances.

Passwords
----------
When you install and launch your instance it is set up with a default set of 
usernames/passwords:

* MySQL root password: 'default'
* MySQL oppia user password: 'default' - this is the user that Django uses to 
  connect to your database. When you have changed this password you should also 
  update the django settings.py file (at: 
  ``/home/oppiamobile/oppia_web/oppia_web/settings.py``) to reflect the new 
  database password.
* Django super user: username 'admin' and password 'default'
	
.. warning:: 
	You are very strongly advised to change these passwords as soon as 
	you have set up your instance

Directories and location of files
---------------------------------
All the required files are stored in the /home/oppiamobile directory, which has 
the following structure:

* django-oppia (dir): the OppiaMobile server application files
* env (dir): root of the `virtualenv <http://www.virtualenv.org/en/latest/>`_
* media (dir): the media directory for Django (this directory served directly by 
  Apache)
* oppia-cron.sh (file): a shell script for running the OppiaMobile cron task - it's 
  unlikely you'll ever need to do anything with this file.
* oppia_web (dir): the Django project files (containing settings.py and urls.py etc)
* static (dir): the static directory for Django (this directory is served directly by 
  Apache)
* upload (dir): stores the course uploads

Please note that on this machine the django-oppia server is installed as a clone 
from GitHub (rather than using the pip install method described in the :ref:`standard 
installation instructions <install>`). 


Updating django-oppia server code from core
--------------------------------------------
The code is based on a 'point-in-time' version of the OppiaMobile server code, 
so once you have set up your instance, you should try to keep it up to date. 
Fortunately it's straightforward to update to the latest version:

* Go into the ``/home/oppiamobile/django-oppia/`` directory
* Run ``git pull``

This will update your server to the latest version of the django-oppia server. 
If any new updates were made, run the following commands (when 
the virtualenv is active):

* ``python manage.py migrate oppia``
* ``python manage.py migrate oppia.quiz``
* ``python manage.py migrate oppia.viz``
* ``python manage.py collectstatic``

Creating your own version of django-oppia
-----------------------------------------
If you have created your own fork of django-oppia (for example to customise the 
look and feel), then you can point git to the fork of your code by editing the 
``/home/oppiamobile/django-oppia/.git/config`` file and pulling the code from 
your fork instead.

:ref:`More information on customising OppiaMobile <customisation>`

Environment information
-----------------------
The current version of the instance (OppiaMobile Server 0.4.3) is running:

* Ubuntu 12.04 LTS Server
* Apache 2
* Mysql 5.5
* Django 1.6.1
* TastyPie 0.11.0
* South 0.8.4
* OppiaServer 0.4.3


Email configuration
-------------------
By default your AWS OppiaServer instance is not configured to send email, any 
emails generated by the system (for example reset password messages) are just 
saved as plain text files in the ``/tmp`` directory.

To enable sending email you will need to:

* configure your AWS account to enable email sending (using SES service)
* comment out or remove the ``EMAIL_BACKEND`` and ``EMAIL_FILE_PATH`` directives 
  in the ``/home/oppiamobile/oppia_web/oppia_web/settings.py`` file. 
* update the ``SERVER_EMAIL`` directive in ``settings.py`` to use an email 
  address that is authorised to send via your SES.