-
Notifications
You must be signed in to change notification settings - Fork 43
Setting up backend server
Rison Simon edited this page Apr 4, 2019
·
15 revisions
To setup backend server, follow the steps below.
- Create a new server with Ubuntu 18.04 on any cloud platform. Create a new user called
ubuntu
as non root user. - Run the following commands
sudo apt update
sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools zlib1g-dev
- Install pyenv
curl https://pyenv.run | bash
- Install python 3.6.4
pyenv install 3.6.4
- Use python 3.6.4
pyenv global 3.6.4
- Install virtualenv
pip install virtualenv
- Create new folder called remixvr
mkdir remixvr
- Setup virtualenv
cd remixvr
virtualenv env
source env/bin/activate
- Copy remixvr content to server and install requirements using
pip install -r requirements/dev.txt
. - Install uwsgi
pip install uwsgi
- Setup a new service
sudo vi /etc/systemd/system/remixvr.service
- Copy the following contents in the file. (Reference).
If you're setting up staging and production on the same server make sure to update
remixvr.sock
value in remixvr.ini and setup appropriate nginx setting.
[Unit]
Description=uWSGI instance to serve remixvR
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/remixvr
Environment="PATH=/home/ubuntu/remixvr/env/bin"
ExecStart=/home/ubuntu/remixvr/env/bin/uwsgi --ini remixvr.ini
[Install]
WantedBy=multi-user.target
- Run the following commands.
sudo systemctl start remixvr
sudo systemctl enable remixvr
- Check if it's running by
sudo systemctl status remixvr
- Setup nginx to run with uwsgi. And setup letsencrypt (Reference - from step 6) To install nginx use the following.
sudo apt update
sudo apt install nginx
-
Install postgres and create a new database named
remixvr
. - Create a new user with with password as mentioned in the above article.Make sure the password is also set inside psql by using
ALTER USER db_username PASSWORD 'new_password'
command - We'll use this user to access our database
- Create a
.env
file inremixvr
parent directory and addDATABASE_URL
with database connection url with the format mentioned here. - Restart remixvr service
sudo systemctl restart remixvr
- Setup database
flask db upgrade
- Test everything is working propertly by accessing the api