Skip to content

UTA rest install log

Dave Lawrence edited this page Feb 9, 2022 · 9 revisions
sudo bash
apt-get update
apt-get upgrade -y

apt-get install -y git-core python3-venv redis nginx
apt-get install -y libpq-dev gcc python3-dev # For building psycopg2

# Users and source code

SYSTEM_UTA_REST_USER=uta_rest
UTA_REST_INSTALL_DIR=/opt/uta_rest

id -u ${SYSTEM_UTA_REST_USER} &>/dev/null || useradd ${SYSTEM_UTA_REST_USER} --create-home --shell "/bin/bash"
mkdir -p ${UTA_REST_INSTALL_DIR}
chown ${SYSTEM_UTA_REST_USER} ${UTA_REST_INSTALL_DIR}
chgrp ${SYSTEM_UTA_REST_USER} ${UTA_REST_INSTALL_DIR}

su ${SYSTEM_UTA_REST_USER}
UTA_REST_INSTALL_DIR=/opt/uta_rest  # Again for user
cd ${UTA_REST_INSTALL_DIR}
if [ ! -e ${UTA_REST_INSTALL_DIR}/.git ]; then
    git clone https://github.com/sacgf/uta_rest.git .
fi

# Install Python libraries
mkdir venv
python3 -m venv venv/uta_rest
source /opt/uta_rest/venv/uta_rest/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install gunicorn # Install into venv so it gets libraries
python3 -m pip install -r requirements.txt
exit # Back to root shell

# Install services

###### Manual step
# Find your IP address via: ip a | grep "inet .*eth"
# edit ${UTA_REST_INSTALL_DIR}/uta_rest/settings.py
# Add your IP address as a quoted string to the ALLOWED_HOSTS list

mkdir -p /var/log/uta_rest
chown uta_rest /var/log/uta_rest
cp ${UTA_REST_INSTALL_DIR}/config/gunicorn.service /lib/systemd/system
systemctl enable gunicorn
service gunicorn start

mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ORIG
cp ${UTA_REST_INSTALL_DIR}/config/nginx.conf /etc/nginx/
service nginx restart
Clone this wiki locally