carom-server/INSTALL.md

200 lines
4.3 KiB
Markdown
Raw Normal View History

2019-02-19 14:16:04 +01:00
# Preparing
2019-02-19 14:18:06 +01:00
- [ ] Install and configure Mailsystem (postfix) so it is possible to send mails
2019-02-20 08:12:15 +01:00
- [ ] Install python ```apt install python3 python3-pip python3-venv python3-virtualenv```
- [ ] Install uwsgi ```apt install uwsgi uwsgi-plugin-python3```
2019-02-19 16:00:34 +01:00
- [ ] Install and configure mariadb-server ```mysql_secure_installation```
2019-02-20 08:12:15 +01:00
- [ ] Install and configure nginx und let's encrypt or similar
2019-02-23 23:25:46 +01:00
- [ ] Install git ```apt install git```
2019-02-19 14:16:04 +01:00
2019-02-19 14:19:36 +01:00
2019-02-19 14:16:04 +01:00
# Installation
2019-02-19 14:19:36 +01:00
- [ ] Create databases for carom and carom-int
2019-02-19 14:16:04 +01:00
```
-- carom
CREATE DATABASE carom DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'carom'@'localhost' IDENTIFIED BY 'xxx';
GRANT ALL PRIVILEGES ON carom.* TO 'carom'@'localhost';
2019-02-25 09:21:32 +01:00
CREATE DATABASE `carom-int` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
2019-02-23 23:07:41 +01:00
CREATE USER 'carom-int'@'localhost' IDENTIFIED BY 'xxx';
2019-02-25 09:21:32 +01:00
GRANT ALL PRIVILEGES ON `carom-int`.* TO 'carom-int'@'localhost';
2019-02-19 14:16:04 +01:00
FLUSH PRIVILEGES;
```
2019-02-20 08:12:15 +01:00
Passphrases should be replaced by useful characters
2019-02-19 14:16:04 +01:00
2019-02-19 14:19:36 +01:00
- [ ] Create systemd unit file for uwsgi (/etc/systemd/system/uwsgi.service):
2019-02-19 14:16:04 +01:00
```
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown www-data:www-data /run/uwsgi'
ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/apps-enabled
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
```
2019-02-20 08:12:15 +01:00
- [ ] Reread systemd configs for uwsgi
```
2019-02-20 18:12:53 +01:00
systemctl daemon-reload
2019-02-23 23:21:44 +01:00
systemctl enable uwsgi.service
systemctl restart uwsgi.service
2019-02-20 08:12:15 +01:00
```
2019-02-19 14:19:36 +01:00
- [ ] Checkout carom
2019-02-19 14:16:04 +01:00
```
cd /srv
git clone http://git.einsle.de/carom/carom-server.git carom
git clone http://git.einsle.de/carom/carom-server.git carom-int
cd carom-int
git checkout develop
git pull
cd ..
```
2019-02-19 14:19:36 +01:00
- [ ] Install pipenv
2019-02-19 14:16:04 +01:00
```
2019-02-25 09:21:04 +01:00
pip3 install upgrade pipenv
2019-02-19 14:16:04 +01:00
```
2019-02-25 09:19:43 +01:00
- [ ] Install mysqlclient
2019-02-25 09:22:26 +01:00
```
2019-02-25 09:19:43 +01:00
apt install libmariadbclient-dev
2019-02-25 09:22:26 +01:00
```
2019-02-25 09:19:43 +01:00
In environments carom run
```
pipenv install mysqlclient
```
```
2019-02-25 09:21:04 +01:00
git checkout -- Pipfile Pipfile.lock
2019-02-25 09:19:43 +01:00
git status
```
2019-02-19 14:19:36 +01:00
- [ ] Create caromserver/local_settings.py for both environments:
2019-02-19 14:16:04 +01:00
```
cd caromserver
cp local_settings_example.py local_settings.py
vi local_settings.py
ALLOWED_HOSTS, ADMINS, DEBUG should be filled
SECRET_KEY use pwgen 50 1 to create content for
DATABASES settings
cd ..
mkdir .venv
pipenv install
pipenv run python manage.py migrate
pipenv run python manage.py collectstatic
```
Do it for /srv/carom and /srv/carom-int
2019-02-20 08:12:15 +01:00
- [ ] Create Superuser Accounts using:
2019-02-19 14:19:36 +01:00
```
pipenv run python manage.py createsuperuser
```
- [ ] Create config File for uwsgi/carom
2019-02-19 14:16:04 +01:00
```
# carom...ini file
[uwsgi]
plugin = python3
chdir = /srv/carom/
module = caromserver.wsgi:application
home = /srv/carom/.venv/
master = true
processes = 5
vacuum = true
uid = www-data
gid = www-data
workers = 2
2019-02-25 09:34:15 +01:00
socket = /run/uwsgi/carom.socket
2019-02-19 14:16:04 +01:00
chmod-socket = 660
log-date = true
```
2019-02-19 14:22:59 +01:00
Create it for /etc/uwsgi/apps-available/carom.ini and carom-int.ini and link it
2019-02-19 14:16:04 +01:00
to /etc/uwsgi/apps-enabled/
2019-02-19 14:20:18 +01:00
2019-02-20 08:12:15 +01:00
```
systemctl restart uwsgi.service
```
2019-02-19 14:20:18 +01:00
2019-02-19 14:16:04 +01:00
Show at syslog for errors and fix it.
2019-02-19 14:19:36 +01:00
- [ ] Create Config File for nginx/carom
2019-02-19 14:16:04 +01:00
```
upstream socket_carom {
2019-02-25 09:47:52 +01:00
server unix:///run/uwsgi/carom.socket;
2019-02-19 14:16:04 +01:00
}
server {
listen 80;
listen [::]:80;
server_name carom...;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name carom...;
ssl_certificate /etc/ssl/certs/xxx;
ssl_certificate_key /etc/ssl/private/xxx;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /media {
alias /srv/carom/media;
}
location /static {
2019-02-25 10:01:06 +01:00
alias /srv/carom/staticfiles;
2019-02-19 14:16:04 +01:00
}
location / {
uwsgi_pass socket_carom;
include /etc/nginx/uwsgi_params;
}
}
```
Create it for /etc/ngin/sites-available/carom... and carom-int... and link it
to /etc/ngin/sites-enabled/
2019-02-19 14:20:18 +01:00
2019-02-19 14:28:42 +01:00
Path to certificates must be modified.
2019-02-20 08:12:15 +01:00
```
2019-02-19 14:16:04 +01:00
systemctl restart nginx
2019-02-20 08:12:15 +01:00
```
2019-02-19 14:22:59 +01:00
2019-02-19 14:28:42 +01:00
- [ ] Create update.sh in carom and carom-int root dir
2019-02-19 14:22:59 +01:00
```
pushd /srv/carom/
git pull
pipenv update
2019-02-25 10:04:56 +01:00
pipenv run python manage.py migrate
pipenv run python manage.py collectstatic --noinput
2019-02-19 14:22:59 +01:00
touch /etc/uwsgi/apps-enabled/carom.ini
popd
```
2019-02-20 08:12:15 +01:00
Path to uwsgi config file (in apps-enabled) musst be matching.