Commit f1c5c2ba authored by David Seaward's avatar David Seaward

add Nginx instructions and files

parent 1209fa79
......@@ -11,8 +11,9 @@ Prerequisites
-------------
* Debian 8
* Python 3.4 / 3.5
* Debian packages:
* Python 3.4 or 3.5
* Nginx
* Additional Debian packages:
* `libsasl2-dev`
* `libldap2-dev`
* `libssl-dev`
......@@ -20,7 +21,7 @@ Prerequisites
* Python/Django packages: see `requires/requirements.txt`
* Includes Django 1.10
Other versions may work but are untested.
Other versions and alternatives may work but are untested.
Setup
-----
......@@ -28,7 +29,7 @@ Setup
* Create project folders:
* `/opt/purist_account/` (code)
* `/etc/opt/purist_account/` (configuration)
* `/var/opt/purist_account/static/` (static web files)
* `/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` ...)
......@@ -37,14 +38,17 @@ Setup
* Activate virtualenv (`./bin/activate.py`)
* Install Python packages (`pip install -r requires/requirements.txt`)
* Complete Django settings
* `cp ./conf/config.ini /etc/opt/purist_account/`
* `cp ./conf/secret.ini /etc/opt/purist_account/`
* `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`
* When prompted, enter the credentials of your LDAP superuser /
account manager
* Hook up Django site to webserver (i.e. Apache HTTPD, Nginx...)
* 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`)
......
# stored as /etc/nginx/sites-available/purist_account
# and symlink /etc/nginx/sites-enabled/purist_account
# the upstream component nginx needs to connect to
upstream django {
server unix:/var/opt/purist_account/uwsgi.sock; # for a file socket
}
# the upstream component nginx needs to connect to
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
charset utf-8;
location /static/ {
alias /var/opt/purist_account/static;
}
location /favicon.ico {
alias /var/opt/purist_account/favicon.ico;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}
......@@ -8,8 +8,11 @@ from decouple import Config, Csv, RepositoryIni
# LOAD CONFIGURATION FILE
#
config = Config(RepositoryIni('/etc/opt/purist_account/config.ini'))
secret_config = Config(RepositoryIni('/etc/opt/purist_account/secret.ini'))
CONFIG_PATH = '/etc/opt/purist_account/config.ini'
SECRET_PATH = '/etc/opt/purist_account/secret.ini'
config = Config(RepositoryIni(CONFIG_PATH))
secret_config = Config(RepositoryIni(SECRET_PATH))
#
# SECURITY
......@@ -71,6 +74,8 @@ AUTH_USER_MODEL = 'ldapregister.User'
# and https://pypi.python.org/pypi/django-ldapdb/
# (re-uses LDAP connection details from authentication settings)
SQLITE_DB_PATH = config("SQLITE_DB_PATH")
DATABASES = {
'ldap': {
'ENGINE': 'ldapdb.backends.ldap',
......@@ -81,7 +86,7 @@ DATABASES = {
},
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': SQLITE_DB_PATH,
},
}
......
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