Skip to content

Commit

Permalink
Merge pull request #57 from demostat/enhancement/docs
Browse files Browse the repository at this point in the history
Enhancement/docs
  • Loading branch information
clerie committed Mar 17, 2019
2 parents 5174990 + e371855 commit 35ecfc2
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 133 deletions.
134 changes: 7 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,139 +26,19 @@ Jeder Demo wir ein Ort und eine Organisation zugeordnet. Neben Name und kurzer B
### Organisation
Jede Organisation hat einen Namen, eine kurze Beschreibung und einen Link zur Homepage.

## Installation
## Dokumentation & Installation

## Live Betrieb
https://docs.demostat.de

Um MySQL als Datenbank zu nutzen mus folgendes Paket installiert werden:
### Selber bauen

```bash
apt install default-libmysqlclient-dev
```

In dem Ordner welcher genutzt werden soll folgende Befehle ausführen

```bash
git clone git@github.com:demostat/demostat.git
pip3 install -r demostat/requirements.txt # Abhängigkeiten installieren
django-admin startproject mysite # Hierfür muss vorher(!) pip3 install django als **root** ausgeführt werden damit der Befehl global verfügbar ist
cd mysite
ln -s ../demostat/demostat
```

In der `mysite/settings.py` müsen folgende Zeilen zu `INSTALLED_APPS` hinzugefügt werden:

```python
INSTALLED_APPS = [
'demostat',
'taggit',
...
]
```

In der `mysite/settings.py` müsen nun die demostat Routen geladen werden:

```python
from django.urls import include

urlpatterns = [
path('', include('demostat.urls')),
...
]
```

Wenn MySQL als Datenbank genutzt werden soll müssen folgende änderungen in der `mysite/settings.py` vorgenommen werden:
```python
# Verbindung zu der Datenbank
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'demostat',
'USER': 'demostat',
'PASSWORD': '<password>',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", # Sicherheitsmaßnahme um das Schreiben von Fehlerhaften Daten zu verhindern https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode
},
}
}

[...]
# Falls MySQL genutzt werden soll
# Dies ist ein Workarround um Probleme mit dem Filtern nach dem Datum zu beheben. Siehe https://stackoverflow.com/a/22043578/7142167
USE_TZ = False

[...]

# Damit statische files ordentlich ausgelagert werden
STATIC_URL = '/static/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, '../static')

```

Nun müssen die migrations ausgeführt werden:

```python
python3 manage.py migrate
```

Statische Dateien auslagern:

```python
python3 manage.py collectstatic
pip3 install sphinx
cd docs/
make html
```

Superuser werden über folgenden Befehl angelegt:

```python
python3 manage.py createsuperuser
```

### Unter Apache zum Laufen bringen
_Diese sektion orrientiert basiert mehr oder weniger auf Justin Ellingwood's [How To Serve Django Applications with Apache and mod_wsgi on Ubuntu 14.04 ](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04)_


Vorrausgesetzt ist dabei, dass bereits apache2 installiert ist.
```bash
apt install libapache2-mod-wsgi-py3
```

Virtual host für Apache:

```apache
<VirtualHost *:80>
. . .
Alias /static /path/to/mysite/static
<Directory /path/to/mysite/static>
Require all granted
</Directory>
<Directory /path/to/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-path=/path/to/mysite python-home=/home/user/myproject/myprojectenv ## auskommentieren wenn ein virtual env verwendet werden soll
WSGIDaemonProcess myproject python-path=/path/to/mysite
WSGIProcessGroup mysite
WSGIScriptAlias / /path/to/mysite/mysite/wsgi.py
</VirtualHost
```

```bash
a2ensite mysite.conf
systemctl reload apache2
```

**Wenn änderungen in der `mysite/settings.py` vorgenommen werden, muss apache neu geladen werden!**

```bash
systemctl reload apache2
```
Die fertigen HTML sind dann unter `docs/_build/html/` verfügbar.

## Lizenz
Diese Software hat **noch** keine Lizenz. Das bedeutet, dass das deutsche Urherberrecht gilt.
Expand Down
160 changes: 158 additions & 2 deletions docs/deploy.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,164 @@
############
Installieren
============
############

.. toctree::
:maxdepth: 4
:caption: Contents:

Produktivsystem
===============

Um MySQL als Datenbank zu nutzen muss folgendes Paket installiert werden:

::

apt install default-libmysqlclient-dev


In dem Ordner welcher genutzt werden soll folgende Befehle ausführen

::

git clone git@github.com:demostat/demostat.git
pip3 install -r demostat/requirements.txt # Abhängigkeiten installieren
django-admin startproject mysite # Hierfür muss vorher(!) pip3 install django als **root** ausgeführt werden damit der Befehl global verfügbar ist
cd mysite
ln -s ../demostat/demostat


In der `mysite/settings.py` müsen folgende Zeilen zu `INSTALLED_APPS` hinzugefügt werden:

::

INSTALLED_APPS = [
'demostat',
...
]


In der `mysite/settings.py` müsen nun die demostat Routen geladen werden:

::

from django.urls import include

urlpatterns = [
path('', include('demostat.urls')),
...
]


Wenn MySQL als Datenbank genutzt werden soll müssen folgende änderungen in der `mysite/settings.py` vorgenommen werden:

::

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'demostat',
'USER': 'demostat',
'PASSWORD': '<password>',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", # Sicherheitsmaßnahme um das Schreiben von Fehlerhaften Daten zu verhindern https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode
},
}
}


# Falls MySQL genutzt werden soll
# Dies ist ein Workarround um Probleme mit dem Filtern nach dem Datum zu beheben. Siehe https://stackoverflow.com/a/22043578/7142167

::

USE_TZ = False


# Damit statische files ordentlich ausgelagert werden

::

STATIC_URL = '/static/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, '../static')


Nun müssen die migrations ausgeführt werden:

::

python3 manage.py migrate


Statische Dateien auslagern:

::

python3 manage.py collectstatic


Superuser werden über folgenden Befehl angelegt:

::

python3 manage.py createsuperuser


Unter Apache zum Laufen bringen
===============================

_Diese sektion orrientiert basiert mehr oder weniger auf Justin Ellingwood's [How To Serve Django Applications with Apache and mod_wsgi on Ubuntu 14.04 ](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04)_


Vorrausgesetzt ist dabei, dass bereits apache2 installiert ist.

::

apt install libapache2-mod-wsgi-py3


Virtual host für Apache:

::

<VirtualHost *:80>
. . .

Alias /static /path/to/mysite/static
<Directory /path/to/mysite/static>
Require all granted
</Directory>

<Directory /path/to/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

WSGIDaemonProcess myproject python-path=/path/to/mysite python-home=/home/user/myproject/myprojectenv ## auskommentieren wenn ein virtual env verwendet werden soll
WSGIDaemonProcess myproject python-path=/path/to/mysite
WSGIProcessGroup mysite
WSGIScriptAlias / /path/to/mysite/mysite/wsgi.py
</VirtualHost>


::

a2ensite mysite.conf
systemctl reload apache2


**Wenn änderungen in der `mysite/settings.py` vorgenommen werden, muss apache neu geladen werden!**

::

systemctl reload apache2


Eigenständige Entwicklungsversion
---------------------------------
=================================

Demostat Entwicklungsversion herunterladen:

Expand Down
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Willkommen zu Demostat!
=======================

.. toctree::
:maxdepth: 2
:caption: Contents:
:maxdepth: 2
:caption: Contents:

deploy
conf
deploy
conf

Über
====
Expand Down

0 comments on commit 35ecfc2

Please sign in to comment.