- 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_appdirectory,(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_radioand give it a password - Give the user privileges on the
moth_radiodatabase
- Install the package (e.g.
- Add your MySQL user's password after the
:inmoth_radio/__init__.pywhereapp.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-getup to date:$ sudo apt-get update - Install
nginx:$ sudo apt-get install nginx - Tell the firewall to let
nginxdo its thing:$ sudo ufw allow 'Nginx Full'
Note: ifufwisn'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_radioand two users,moth_radioandmoth_radio_turk, both with full privileges on themoth_radiodatabase. - Install
ffmpeg:$ sudo apt-get install ffmpeg - Install
virtualenv:$ sudo pip install virtualenv - Create a virtual environment in
/var/wwwfor the app:$ virutalenv moth_env - Copy the
moth_appproject 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_appdirectory, install the moth app and its dependencies:$ pip install -e . - Add your
moth_radioMySQL user's password after the:inmoth_radio/__init__.pywhereapp.config['SQLALCHEMY_DATABASE_URI']is set. - Create an empty socket file:
$ touch moth_app.sock - Make sure
/var/wwwhas the right permissions to be served:$ sudo chown -R www-data:www-data /var/www - Install the
moth_app.serviceservice:$ 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_appnginxconfig 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