Commit 442341c2 authored by David Seaward's avatar David Seaward

post-dry-run updates

* expand setup instructions with installation details
* update config examples and home page links
* reorder requirements to match `pip freeze` output
parent 7eb1f17b
......@@ -13,11 +13,15 @@ Prerequisites
* Debian 8
* Python 3.4 or 3.5
* Nginx
* Additional Debian packages:
* Additional dependency packages:
* `libsasl2-dev`
* `libldap2-dev`
* `libssl-dev`
* `python3-dev`
* Additional uWSGI packages:
* `uwsgi`
* `uwsgi-emperor`
* `uwsgi-plugin-python3`
* Python/Django packages: see `requires/requirements.txt`
* Includes Django 1.11
......@@ -26,31 +30,55 @@ Other versions and alternatives may work but are untested.
Setup
-----
* Create project folders:
* Install Debian packages (`apt install libsasl2-dev libldap2-dev...`)
* Create installation folders:
* `/opt/purist/account/` (code)
* `/opt/purist/account_virtualenv/` (Python environment)
* `/etc/opt/purist/account/` (configuration)
* `/var/opt/purist/account/static/` (data and static web files)
* `/var/log/purist/account/` (logs)
* Copy project code into `/opt/purist/account/`
* Install Debian prerequisites (`apt install libsasl2-dev` ...)
* Set up virtualenv
* Create virtualenv in project folder (`virtualenv . --python=python3`)
* Activate virtualenv (`./bin/activate.py`)
* Populate brand data (if it doesn't already exist):
* Create `/var/opt/purist/brand/` (shared data and static web files)
* Populate `brand` folder
* `chown --recursive www-data:www-data /var/opt/purist`
* Copy project code:
* Copy code into `/opt/purist/account/`
* `chown --recursive www-data:www-data /opt/purist`
* Set up virtualenv:
* Create virtualenv (`virtualenv /opt/purist/account_virtualenv --python=python3`)
* `cd /opt/purist/account`
* Activate virtualenv (`source ../account_virtualenv/bin/activate`)
* Install Python packages (`pip install --requirement requires/requirements.txt`)
* Complete Django settings
* Confirm packages by comparing `pip freeze` output with `requires/requirements.txt`
* Deactivate virtualenv (`deactivate`)
* Complete Django settings:
* `cp ./conf/etc/config.ini /etc/opt/purist/account/`
* `cp ./conf/etc/secret.ini /etc/opt/purist/account/`
* Fill in settings
* Run `./manage.py collectstatic`
* Run `./manage.py migrate`
* Run `./manage.py createsuperuser`
* Run initial setup:
* Activate virtualenv (`source ../account_virtualenv/bin/activate`)
* `./manage.py collectstatic`
* `./manage.py migrate`
* `./manage.py createsuperuser`
* When prompted, enter the credentials of your LDAP superuser /
account manager
* Hook up Nginx
* Deactivate virtualenv (`deactivate`)
* Hook up Nginx:
* `cp ./config/nginx/purist_account /etc/nginx/available_sites/`
* `ln -s /etc/nginx/sites-available/purist_account /etc/nginx/sites-enabled/purist_account`
* Hook up system service (i.e. systemd, supervisord...) to runserver
directive (`manage.py runserver`)
* Update `server_name` value
* `cd /etc/nginx/sites-enabled`
* `ln --symbolic ../sites-available/purist_account`
* Hook up uWSGI:
* `sudo apt install uwsgi uwsgi-emperor uwsgi-plugin-python3`
* `cp ./conf/uwsgi_emperor_vassals/purist_account.ini /etc/uwsgi-emperor/vassals/`
* Restart services:
* `sudo service uwsgi-emperor restart`
* `sudo service nginx restart`
* Check logs:
* `/var/log/uwsgi/emperor.log`
* `/var/log/uwsgi/app/purist_account.log`
* `/var/log/nginx/error.log`
* `/var/log/nginx/access.log`
For more options and details see
<https://docs.djangoproject.com/en/1.11/#the-development-process>
......
[settings]
# stored as /etc/opt/purist/account/config.ini
# note that % must be escaped as %%
[settings]
SITE_TITLE=Title
SITE_BYLINE=Example byline
DEBUG=True
ALLOWED_HOSTS=localhost
STATIC_ROOT = /var/opt/purist/account/static
......
[settings]
# stored as /etc/opt/purist/account/secret.ini
# note that % must be escaped as %%
[settings]
DJANGO_SECRET_KEY=random_key
AUTH_LDAP_BIND_PASSWORD=ldap_password
......@@ -3,23 +3,23 @@
# the upstream component nginx needs to connect to
upstream django {
server unix:/var/opt/purist_account/uwsgi.sock; # for a file socket
server unix:/var/opt/purist/account/uwsgi.sock; # for a file socket
}
# the upstream component nginx needs to connect to
# the main server block
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
server_name example.com; # change this
charset utf-8;
location /static/ {
alias /var/opt/purist_account/static;
alias /var/opt/purist/account/static/;
}
location /favicon.ico {
alias /var/opt/purist_account/favicon.ico;
alias /var/opt/purist/brand/favicon.ico;
}
location / {
......@@ -27,4 +27,3 @@ server {
include /etc/nginx/uwsgi_params;
}
}
# stored as /etc/uwsgi-emperor/vassals/purist_account.ini
[uwsgi]
socket = /var/opt/purist/account/uwsgi.sock
chmod-socket = 775
chdir = /opt/purist/account
master = true
virtualenv = /opt/purist/account_virtualenv
env = DJANGO_SETTINGS_MODULE=purist_account.settings
module = purist_account.wsgi:application
uid = www-data
gid = www-data
processes = 1
threads = 1
plugins = python3,logfile
logger = file:/var/log/uwsgi/app/purist_account.log
vacuum = true
......@@ -27,12 +27,12 @@
<p>
<a href="https://plan.puri.st">plan</a> | <a href="https://code.puri.sm/purist">code</a> |
<a href="http://dev.comms.puri.st:8000">test</a> | <a href="/admin/">admin</a>
<a href="http://dev.comms.puri.st">test</a> | <a href="/admin/">admin</a>
</p>
<p style="font-size: small">
Services provided by <a href="https://puri.sm">Purism SPC</a>. Stand-in logo from
<a href="https://openclipart.org/detail/158443/kawaii-rainbow">Openclipart</a> [CC0].
<a href="https://plan.puri.st/project/overview/design/logo">Openclipart</a> [CC0].
</p>
</body>
......
Django==1.11.2
Jinja2==2.9.6
dj-database-url==0.4.2
django-auth-ldap==1.2.13
django-crispy-forms==1.6.1
django-ldapdb==0.9.0
django-registration==2.2
Jinja2==2.9.6
jinja2-django-tags==0.5
pyasn1==0.2.3
python-decouple==3.0
dj-database-url==0.4.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment