- Clone this repository
- Navigate to project directory:
$ cd ~/path/to/moth_app
- Install virtualenv:
$ sudo pip install virtualenv
- Create a virtual environment for the app somewhere handy, e.g.
$ virtualenv venv/
- Activate the virtual environment, e.g.
$ . venv/bin/activate
- Install Flask in the virutal environment:
(venv)$ sudo pip install Flask
- Install the moth app and its dependencies: from the
moth_app
directory,(venv)$ pip install -e .
- Tell Flask which app you want:
(venv)$ export FLASK_APP=moth_radio
- Enable debug mode:
(venv)$ export FLASK_DEBUG=true
- Install ffmpeg (e.g.
(venv)$ brew install ffmpeg
). Required to add stimuli to the database, but not for running trials - Install MySQL
- Install the package (e.g.
(venv)$ brew install mysql
) - Create a database
moth_radio
- Create a user
moth_radio
and give it a password - Give the user privileges on the
moth_radio
database
- Install the package (e.g.
- Add your MySQL user's password after the
:
inmoth_radio/__init__.py
whereapp.config['SQLALCHEMY_DATABASE_URI']
is set. - Start the app:
(venv)$ flask run
- Deactivate the virtual environment when finished:
(venv)$ deactivate
Assumes a clean install of Ubuntu 16.04.3 LTS.
- Get
apt-get
up to date:$ sudo apt-get update
- Install
nginx
:$ sudo apt-get install nginx
- Tell the firewall to let
nginx
do its thing:$ sudo ufw allow 'Nginx Full'
Note: ifufw
isn't enabled, you probably want to enable it. Just make sure it's configured not to block things you need, e.g.ssh
. - Install Python:
$ sudo apt-get install python
- Install
pip
:$ sudo apt-get install python-pip
Note: if you're ssh'd in from a Mac and get locale-related problems, try$ export LC_ALL="en_US.UTF-8"
- Install MySQL:
$ sudo apt-get install mysql-server
. Set a password for the root user when prompted. - Install the MySQL dev tools:
$ sudo apt-get install libmysqlclient-dev
- Create a database
moth_radio
and two users,moth_radio
andmoth_radio_turk
, both with full privileges on themoth_radio
database. - Install
ffmpeg
:$ sudo apt-get install ffmpeg
- Install
virtualenv
:$ sudo pip install virtualenv
- Create a virtual environment in
/var/www
for the app:$ virutalenv moth_env
- Copy the
moth_app
project folder into/var/www
: (from your machine)$ scp -r moth_app user@cosanlabradio:/var/www/
- Activate the environment:
$ source moth_env/bin/activate
- From the
moth_app
directory, install the moth app and its dependencies:$ pip install -e .
- Add your
moth_radio
MySQL user's password after the:
inmoth_radio/__init__.py
whereapp.config['SQLALCHEMY_DATABASE_URI']
is set. - Create an empty socket file:
$ touch moth_app.sock
- Make sure
/var/www
has the right permissions to be served:$ sudo chown -R www-data:www-data /var/www
- Install the
moth_app.service
service:$ sudo mv moth_app.service /etc/systemd/system/
- Start the service:
$ sudo systemctl daemon-reload $ sudo systemctl start moth_app $ sudo systemctl enable moth_app
- Install the
moth_app
nginx
config file:$ sudo mv moth_app /etc/nginx/sites-available
- Symlink the same config file to
sites-enabled
:$ sudo ln -s /etc/nginx/sites-available/moth_app /etc/nginx/sites-enabled/
- Restart
nginx
:$ sudo systemctl restart nginx
- Restart the server:
$ sudo reboot