Installing wq and Apache on Ubuntu 16.04 LTS

wq version: 1.1 1.2/1.3
Docs > Overview

If you are starting a new self-hosted project, you may be interested in Digital Ocean, which provides dedicated Linux virtual machines starting at $5 a month. Use this referral link to get a $10 starting credit - which can equate to getting your first two months free!

Installing wq and Apache on Ubuntu 16.04 LTS

The wq framework is designed to create fully custom applications, so most wq-powered projects eventually require running a public web server and installing a number of software packages. If you are planning to self-host, you can follow the process below to get an application up and running. (Be sure to use the referral link above to get a discount on hosting fees!)

Note: If you are only experimenting with wq on your local machine, you may want to try Installing wq locally instead of the more complex process documented here.

Another Note: If you would rather not run a wq-powered server yourself, you may want to reach out to any of the existing subscription-based projects and "campaign builder" apps to explore potential collaboration. Our partners also provide flexible support plans ranging from a couple of hours of installation support to full-service bespoke design, software development, and application hosting.

To run wq on a public website, you will need a WGSI-capable webserver like Apache, and a database to host the application. You will also need to obtain or configure a DNS record pointing a domain or subdomain to your server. wq.db is generally used with PostgreSQL and PostGIS, but any Django-supported database will work. These instructions assume you will be using Apache and PostGIS. These steps are tested on Ubuntu 16.04 LTS.

We recommend installing wq in a venv virtual environment. This makes it easier to run multiple wq-powered applications on the same server.

# Install system libraries
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-wsgi-py3 postgresql-9.5-postgis-2.2 python3-venv

# To use wq's Node.js/npm integration:
sudo apt-get install nodejs

# Create project directory and venv
export PROJECTSDIR=/path/to/projects #e.g. /var/www
export PROJECTNAME=myproject

sudo mkdir $PROJECTNAME
sudo chown `whoami` $PROJECTNAME
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip # optional

# Install wq within venv
python3 -m pip install wq
wq start $PROJECTNAME .
# Answer prompts for:
#  - Web domain:    (Change to match DNS)
#  - Enable GIS?    (Default is N, change to Y)
#  - Enable npm?    (Leave default as N unless you plan to use npm)
#  - Enable PGB?    (Leave default unless you plan to use PhoneGap Build)
#  - App Bundle ID: (Only required for PGB)

sudo chown www-data media/ # give Apache user permission to save uploads

# Create database
# (edit /etc/postgresql/9.5/main/pg_hba.conf and/or pg_ident.conf to set permissions)
sudo service postgresql restart
createuser -Upostgres $PROJECTNAME
psql -Upostgres $PROJECTNAME -c "CREATE EXTENSION postgis;"

# Install database tables & create admin account
# (edit db/$PROJECTNAME/local_settings.py with database info, if different than above)
cd db/
./manage.py migrate
./manage.py createsuperuser

# Configure and restart Apache
# (edit conf/$PROJECTNAME.conf and verify settings)
sudo ln -s $PROJECTSDIR/$PROJECTNAME/conf/$PROJECTNAME.conf /etc/apache2/sites-available/
sudo a2ensite $PROJECTNAME
# optional: disable existing default site and make $PROJECTNAME the server default
# sudo a2dissite 000-default
sudo a2enmod expires
sudo service apache2 restart

# generate htdocs folder via wq build
./deploy.sh 0.0.1

# To Enable HTTPS:
# (edit conf/$PROJECTNAME.conf, comment out WSGIDaemonProcess line)
# (see https://github.com/certbot/certbot/issues/1820)
sudo apt-get install python-letsencrypt-apache
sudo a2enmod ssl
sudo letsencrypt
# (edit /etc/apache2/sites-enabled/$PROECTNAME-le-ssl.conf, uncomment WSGIDaemonProcess line)

Visit the site in a web browser to verify the new installation. You'll probably need to type in the server's IP address instead of the project name until your DNS is configured. When the application loads, you should see "Hello world! Version 0.0.1", and links to log in and out. You are now ready to start defining and registering Django models which will appear on the home screen after you rebuild the application with deploy.sh.