These instructions were tested using a fresh Centos 7 VM
sudo yum install -y epel-release
sudo yum update -y
sudo yum install -y vim git wget bzip2 nano htop
sudo rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
sudo yum install postgresql95 postgresql95-server postgresql95-libs postgresql95-contrib postgresql95-devel
sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb
sudo service postgresql-9.5 start
sudo chkconfig postgresql-9.5 on
sudo yum install postgis2_95
sudo -u postgres createuser -s centos
sudo -u postgres createuser -s apache
sudo yum install gcc gcc-c++
sudo yum groupinstall "Development Tools"
https://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-centos-7/
curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
---Exit and Re-enter server
nvm install 8.4
nvm alias default 8.4
node --version
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install python36u python36u-pip python36u-devel
python3.6 -V
cd /var/www/html
sudo git clone https://github.com/hotosm/tasking-manager
sudo chown -R centos:centos tasking-manager/
cd tasking-manager/
cd client/
npm install
npm install gulp -g
gulp build
cd ../
python3.6 -m venv ./venv
. ./venv/bin/activate
pip3 install -r requirements.txt
sudo -u postgres psql
CREATE USER "hottm" PASSWORD 'hottm';
CREATE DATABASE "tasking-manager" OWNER "hottm";
\c "tasking-manager";
CREATE EXTENSION postgis;
sudo vim ~/.bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
TM_DB=postgresql://hottm:hottm@localhost/tasking-manager
TM_SECRET=secret-key-here
TM_CONSUMER_KEY=oauth-consumer-key-goes-here
TM_CONSUMER_SECRET=oauth-consumer-secret-key-goes-here
TM_SMTP_PASSWORD=smtp-server-password-here
TASKING_MANAGER_ENV=Dev
export PATH
export TM_DB
export TM_SECRET
export TM_CONSUMER_KEY
export TM_CONSUMER_SECRET
export TM_SMTP_PASSWORD
export TASKING_MANAGER_ENV
source ~/.bash_profile
python3.6 manage.py db upgrade
Test out your current installation
python3.6 manage.py runserver -d
Now try out running the server via gunicorn. This should be installed already in your venv via the project's requirements.txt.
gunicorn manage:application
Or run gunicorn with host if you're using a VM
gunicorn -b 0.0.0.0:8000 -w 7 --timeout 179 manage:application
We want to set up the application with a unix file socket so we can work with NGINX or Apache.
Note that -w 7 means that we have 7 workers. This could be calculated by: ((cores x 2) + 1))
gunicorn -b unix:tm3.sock -w 7 --timeout 179 manage:application
sudo yum install httpd httpd-devel
sudo vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName http://localhost
DocumentRoot /var/www/html/tasking-manager/server/web/static/dist
<Location /api>
ProxyPass http://unix:/var/www/html/tasking-manager/tm3.sock
ProxyPassReverse http://unix:/var/www/html/tasking-manager/tm3.sock
</Location>
</VirtualHost>
Replace the paths to wherever the static assets as well as socket file are on your file system.
sudo service httpd restart
If you're using Apache, skip the Nginx section
sudo yum install nginx
sudo vim /etc/nginx/proxy_params
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sudo vim /etc/nginx/nginx.conf
server {
listen 80;
location / {
root /var/www/html/tasking-manager/server/web/static/dist;
try_files $uri $uri/ @api;
expires max;
client_max_body_size 200M;
access_log off;
}
location @api {
include proxy_params;
proxy_pass http://unix:/var/www/html/tasking-manager/tm3.sock;
}
}
Replace the paths to wherever the static assets as well as socket file are on your file system.
sudo service nginx start
sudo vim /etc/systemd/system/tm3.service
[Unit]
Description=tm3 gunicorn daemon
After=network.target
[Service]
User=centos
Group=centos
WorkingDirectory=/var/www/html/tasking-manager
Environment=TM_DB=postgresql://hottm:hottm@localhost/tasking-manager
Environment=TM_CONSUMER_SECRET=OSM-Oauth-Consumer-Secret-Key
Environment=TM_SECRET=secret-key-here
Environment=TM_CONSUMER_KEY=OSM-Oauth-Consumer-Key
Environment=TM_ENV=Prod
ExecStart=/var/www/html/tasking-manager/venv/bin/gunicorn -b unix:/var/www/html/tasking-manager/tm3.sock -w 7 --timeout 179 manage:application
Restart=always
[Install]
WantedBy=multi-user.target
Set your environment variables, paths, and the correct user for your needs.
You are not HOT, so your production setup will be different. For my personal prod setup, I changed ProdConfig in config.py to:
class ProdConfig(EnvironmentConfig):
APP_BASE_URL = 'http://127.0.0.1'
API_DOCS_URL = f'{APP_BASE_URL}/api-docs/swagger-ui/index.html?' + \
'url=http://127.0.0.1/api/docs'
LOG_DIR = '/var/log/tasking-manager-logs'
LOG_LEVEL = logging.DEBUG
sudo mkdir /var/log/tasking-manager-logs
sudo chmod a+rwx /var/log/tasking-manager-logs
sudo systemctl start tm3
sudo systemctl enable tm3
http://localhost