software:middleware:installation
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Vorhergehende Überarbeitung | |||
software:middleware:installation [2021/03/26 12:00] – jacquesh | — | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | |||
- | ====== Installation der Middleware ====== | ||
- | |||
- | This installs the middleware and the frontend. You also need to install the logger (vzlogger). | ||
- | |||
- | ===== Voraussetzungen ===== | ||
- | * PHP 7.1 (nicht verfügbar in Raspbian Stretch!) | ||
- | * Doctrine 2.5 | ||
- | * MySQL, MariaDB + PDO Treiber | ||
- | * APC (optional, aber empfohlen) | ||
- | * Apache, nginx (optional) | ||
- | |||
- | Es eigenen sich hier Debian oder Ubuntu, sowie für den Raspberry Pi: Raspbian oder Raspbian Light.(" | ||
- | Die Abhängigkeiten lassen sich schnell mit folgendem Befehl installieren: | ||
- | < | ||
- | </ | ||
- | |||
- | Für die manuelle Installation wird zudem " | ||
- | |||
- | ==== Vollautomatisiert mit Ansible und DebOps ==== | ||
- | |||
- | Siehe hierzu [[https:// | ||
- | |||
- | |||
- | ===== Install-Skript (empfohlene Methode) ===== | ||
- | < | ||
- | wget https:// | ||
- | </ | ||
- | < | ||
- | bash install.sh | ||
- | </ | ||
- | |||
- | Das sollte dann ablaufen: | ||
- | |||
- | < | ||
- | pi@raspberrypi: | ||
- | volkszaehler.org installation script | ||
- | |||
- | checking prerequisites: | ||
- | | ||
- | awk: / | ||
- | sed: /bin/sed | ||
- | grep: /bin/grep | ||
- | wget: / | ||
- | | ||
- | | ||
- | git: / | ||
- | |||
- | checking php version: 7.3.3-1 >= 7.1, ok | ||
- | |||
- | volkszaehler setup... | ||
- | volkszaehler path? [/ | ||
- | git clone volkszaehler.org into / | ||
- | Cloning into '/ | ||
- | remote: Enumerating objects: 4, done. | ||
- | remote: Counting objects: 100% (4/4), done. | ||
- | remote: Compressing objects: 100% (4/4), done. | ||
- | remote: Total 11981 (delta 0), reused 0 (delta 0), pack-reused 11977 | ||
- | Receiving objects: 100% (11981/ | ||
- | Resolving deltas: 100% (6760/ | ||
- | link from webserver to volkszaehler directory? [/ | ||
- | linking / | ||
- | |||
- | checking composer... | ||
- | composer: / | ||
- | |||
- | installing dependencies... | ||
- | ~/ | ||
- | Loading composer repositories with package information | ||
- | Updating dependencies | ||
- | Package operations: 52 installs, 0 updates, 0 removals | ||
- | - Installing symfony/ | ||
- | - Installing symfony/ | ||
- | - Installing symfony/ | ||
- | - Installing ralouphie/ | ||
- | - Installing psr/ | ||
- | - Installing guzzlehttp/ | ||
- | - Installing react/ | ||
- | - Installing react/ | ||
- | - Installing react/ | ||
- | - Installing evenement/ | ||
- | - Installing react/ | ||
- | - Installing react/cache (v0.5.0): Downloading (100%) | ||
- | - Installing react/dns (v0.4.16): Downloading (100%) | ||
- | - Installing react/ | ||
- | - Installing ratchet/ | ||
- | - Installing cboden/ | ||
- | - Installing symfony/ | ||
- | - Installing symfony/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing doctrine/ | ||
- | - Installing symfony/ | ||
- | - Installing symfony/ | ||
- | - Installing guzzlehttp/ | ||
- | - Installing guzzlehttp/ | ||
- | - Installing influxdb/ | ||
- | - Installing symfony/ | ||
- | - Installing andig/ | ||
- | - Installing andig/ | ||
- | - Installing react/ | ||
- | - Installing ringcentral/ | ||
- | - Installing react/http (v0.8.4): Downloading (100%) | ||
- | - Installing http-interop/ | ||
- | - Installing psr/log (1.1.0): Downloading (100%) | ||
- | - Installing symfony/ | ||
- | - Installing symfony/ | ||
- | - Installing paragonie/ | ||
- | - Installing monolog/ | ||
- | - Installing react/ | ||
- | - Installing symfony/ | ||
- | - Installing php-pm/ | ||
- | - Installing php-pm/ | ||
- | - Installing webpatser/ | ||
- | Package http-interop/ | ||
- | Writing lock file | ||
- | Generating autoload files | ||
- | ~ | ||
- | |||
- | volkszaehler.org is not configured yet. creating new config from sample config file. | ||
- | mysql root user? [root] | ||
- | mysql root password? [] raspberry | ||
- | mysql database? [volkszaehler] | ||
- | mysql admin to volkszaehler database? [vz-admin] | ||
- | mysql admin password? [] secure | ||
- | mysql user? [vz] | ||
- | mysql password? [demo] | ||
- | |||
- | create volkszaehler.org database and admin user? [y] | ||
- | creating database volkszaehler... | ||
- | creating db user vz-admin... | ||
- | creating database schema... | ||
- | ~/ | ||
- | |||
- | ! | ||
- | ! [CAUTION] This operation should not be executed in a production environment! | ||
- | ! | ||
- | |||
- | | ||
- | |||
- | |||
- | [OK] Database schema created successfully! | ||
- | |||
- | |||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | Proxy classes generated to "/ | ||
- | ~ | ||
- | |||
- | create volkszaehler.org database user? [y] | ||
- | creating db user vz with proper rights... | ||
- | |||
- | allow channel deletion? [n] y | ||
- | granting db user vz delete rights... | ||
- | |||
- | insert demo data in to database? [n] | ||
- | |||
- | </ | ||
- | |||
- | Das Script fragt, was es wohin installieren soll. | ||
- | |||
- | ===== Webserver einrichten ===== | ||
- | Im Folgenden sind 3 mögliche Serverkonfigurationen beschrieben. Für Kompatibiltät mit alten Scripts und Konfigurationen empfehlen wir bei PPM zusätzlich einen Proxy einzurichten. | ||
- | |||
- | ==== PPM als Server (empfohlene Methode) ==== | ||
- | Der PPM-Webserver auf Basis von PHP läuft wesentlich Performanter als Apache2 und ist gerade auf schwacher Hardware wie RaspberryPi zu empfehlen. In Standardkonfiguration bedient er Anfragen auf Port 8080. | ||
- | |||
- | - Systemd Service einrichten '' | ||
- | [Unit] | ||
- | Description=Volkszaehler.org Middleware | ||
- | After=syslog.target network.target mysql.service | ||
- | Requires= | ||
- | |||
- | [Service] | ||
- | ExecStart=/ | ||
- | ExecReload=/ | ||
- | StandardOutput=journal | ||
- | Restart=always | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target </ | ||
- | - Server Konfiguration anpassen | ||
- | - '' | ||
- | - ändern: ''" | ||
- | - Middleware Weiterleitung '' | ||
- | title: 'Local (default)', | ||
- | url: '' | ||
- | //live: 8082</ | ||
- | - Systemd Service bei boot aktiveren '' | ||
- | - Systemd Service starten '' | ||
- | |||
- | ==== Apache als Proxy (empfohlene Methode) ==== | ||
- | Dazu Apache auf die Weiterleitung zum PPM reduzieren. | ||
- | - Module aktivieren< | ||
- | sudo a2enmod proxy | ||
- | sudo a2enmod proxy_http | ||
- | sudo a2enmod rewrite</ | ||
- | - Rewrite-Proxy aktivieren, '' | ||
- | < | ||
- | RewriteEngine On | ||
- | RewriteRule ^middleware(.php)? | ||
- | RewriteRule ^api(/.*)$ http:// | ||
- | RewriteRule (.*) http:// | ||
- | </ | ||
- | </ | ||
- | - Default VirtualHost bearbeiten: '' | ||
- | DocumentRoot / | ||
- | </ | ||
- | - Apache Config bearbeiten um Rewrite in .htaccess zu erlauben: '' | ||
- | < | ||
- | Options Indexes FollowSymLinks | ||
- | AllowOverride None | ||
- | Require all granted | ||
- | </ | ||
- | </ | ||
- | - Dann den Apache nur noch neu starten '' | ||
- | |||
- | ==== Alternativ: nginx als Proxy ==== | ||
- | Nginx ist ein schlanker Webserver/ | ||
- | |||
- | < | ||
- | sudo apt install nginx | ||
- | sudo rm / | ||
- | sudo nano / | ||
- | </ | ||
- | In diese wird eingefügt: | ||
- | < | ||
- | # Volkszaehler | ||
- | |||
- | include / | ||
- | |||
- | server { | ||
- | listen 80; | ||
- | listen [::]:80; | ||
- | server_name volkszaehler.org; | ||
- | |||
- | location / { | ||
- | proxy_pass http:// | ||
- | include / | ||
- | } | ||
- | |||
- | location /middleware { | ||
- | rewrite ^/ | ||
- | proxy_pass http:// | ||
- | } | ||
- | |||
- | location /api { | ||
- | rewrite ^/api(/.*)? $1; | ||
- | proxy_pass http:// | ||
- | } | ||
- | |||
- | location /frontend { | ||
- | rewrite ^/ | ||
- | proxy_pass http:// | ||
- | } | ||
- | |||
- | # Konfigurationsbeispiel für eigene PHP-Scripte, | ||
- | # von nginx unter http:// | ||
- | # | ||
- | # location /addapp/ { | ||
- | # alias / | ||
- | # index index.nginx-debian.html; | ||
- | # | ||
- | # location ~ \.php { | ||
- | # include snippets/ | ||
- | # fastcgi_param SCRIPT_FILENAME $request_filename; | ||
- | # fastcgi_pass unix:/ | ||
- | # } | ||
- | # } | ||
- | } | ||
- | </ | ||
- | < | ||
- | |||
- | Installieren mit '' | ||
- | Damit der nginx die Config lädt: | ||
- | < | ||
- | sudo ln -s / | ||
- | </ | ||
- | Dann nur noch Starten und in Bootprozess einbinden: | ||
- | < | ||
- | sudo systemctl start nginx | ||
- | sudo systemctl enable nginx | ||
- | </ | ||
- | |||
- | ==== Alternativ: Apache als Server (unter Debian " | ||
- | < | ||
- | * Pakete installieren '' | ||
- | * mod_rewrite aktivieren: '' | ||
- | * Default VirtualHost bearbeiten: '' | ||
- | ' In der Datei, neben ''< | ||
- | < | ||
- | / | ||
- | </ | ||
- | |||
- | * Apache Config bearbeiten um Rewrite zu erlauben: '' | ||
- | * In der Datei den Abschnitt suchen: | ||
- | < | ||
- | < | ||
- | Options Indexes FollowSymLinks | ||
- | AllowOverride None | ||
- | Require all granted | ||
- | </ | ||
- | </ | ||
- | * in '' | ||
- | |||
- | Nach dem editieren und abspeichern der Datei '' | ||
- | |||
- | Sollte es zu einem PHP Fehler beim Anlegen der Datenbank kommen versucht mal Doctrine per Hand zu Installieren. | ||
- | |||
- | ==== Alternativ: nginx als Server ==== | ||
- | < | ||
- | < | ||
- | server { | ||
- | listen 80; | ||
- | listen [::]:80; | ||
- | server_name volkszaehler.org; | ||
- | |||
- | root / | ||
- | |||
- | index index.php index.html; | ||
- | |||
- | location / { | ||
- | try_files $uri $uri/ =404; | ||
- | } | ||
- | location ~ \.php { | ||
- | include snippets/ | ||
- | # # With php7-cgi alone: | ||
- | # | ||
- | # With php7-fpm: | ||
- | fastcgi_pass unix:/ | ||
- | } | ||
- | } | ||
- | </ | ||
- | < | ||
- | |||
- | Wichtig ist dass in der config in der Zeile " | ||
- | |||
- | |||
- | ===== Manuelle Installation ===== | ||
- | |||
- | === Download der volkszaehler.org Skripte === | ||
- | Download der Skripte aus dem git Repository: | ||
- | < | ||
- | git clone git:// | ||
- | sudo ln -sf ~/ | ||
- | sudo chown -R www-data / | ||
- | </ | ||
- | |||
- | === Installation der benötigten Module === | ||
- | |||
- | == Zunächst PHP Paketmanager Composer von getcomposer.org installieren == | ||
- | |||
- | < | ||
- | cd /tmp | ||
- | curl -sS https:// | ||
- | sudo mv composer.phar / | ||
- | sudo chmod +x / | ||
- | </ | ||
- | |||
- | == Ahängigkeiten laden und installieren (v.a. Doctrine) == | ||
- | |||
- | < | ||
- | cd / | ||
- | composer install | ||
- | </ | ||
- | |||
- | === Konfiguration der Middleware === | ||
- | < | ||
- | cd / | ||
- | cp config.dist.yaml config.yaml | ||
- | </ | ||
- | edit config.yaml: | ||
- | < | ||
- | db: | ||
- | host: 127.0.0.1 | ||
- | port: 3306 | ||
- | user: vz | ||
- | password: demo | ||
- | dbname: volkszaehler | ||
- | </ | ||
- | |||
- | Alternativ wird die Installation in der [[http:// | ||
- | |||
- | === Datenbank konfigurieren === | ||
- | * Datenbank-User anlegen: | ||
- | |||
- | < | ||
- | phpmyadmin: | ||
- | Home -> " | ||
- | Benutzername: | ||
- | Host: localhost | ||
- | Passwort: < | ||
- | keine globalen Rechte vergeben! | ||
- | -> ok | ||
- | oder: | ||
- | CREATE USER ' | ||
- | </ | ||
- | |||
- | * Datenbank anlegen: | ||
- | < | ||
- | phpmyadmin | ||
- | Home -> " | ||
- | oder: | ||
- | CREATE DATABASE `volkszaehler`; | ||
- | </ | ||
- | |||
- | * Tabellen anlegen: | ||
- | < | ||
- | # cd / | ||
- | # php bin/ | ||
- | ATTENTION: This operation should not be executed in a production environment. | ||
- | |||
- | Creating database schema... | ||
- | Database schema created successfully! | ||
- | </ | ||
- | |||
- | * Demoinhalte importieren: | ||
- | < | ||
- | Tabelle " | ||
- | " | ||
- | </ | ||
- | oder: | ||
- | < | ||
- | cd / | ||
- | cat entities.sql properties.sql data-demoset1.sql | mysql -uroot volkszaehler -p | ||
- | </ | ||
- | |||
- | * Rechte setzen: | ||
- | < | ||
- | |||
- | Datenbank " | ||
- | " | ||
- | Host: " | ||
- | Db: " | ||
- | User: " | ||
- | Table_name: " | ||
- | Table_priv: " | ||
- | | ||
- | oder: | ||
- | GRANT select, update, insert ON volkszaehler.* TO vz@localhost; | ||
- | </ | ||
- | |||
- | * Nun noch ein Passwort für den mysql-Administrator " | ||
- | < | ||
- | mysqladmin password -u root "< | ||
- | mysqladmin reload -p | ||
- | </ | ||
- | |||
- | === Webserver === | ||
- | Wie bereits [[/ | ||
- | |||
- | ====== Aktualisierung der Middleware einschließlich des Frontends ====== | ||
- | |||
- | Hierzu kann ebenfalls das [[software: | ||
- | |||
- | Nachdem Volkszähler im Zuge der Installation eine Kopie des git Repositories erstellt, kann die Installation aber auch aus diesem Repository aktualisiert werden. Eine Beschreibung findet sich im Kapitel zu [[/ | ||
- | |||
- | |||
- | ====== phpMyAdmin installieren ====== | ||
- | < | ||
- | <note important> | ||
- | MySQL-Superuser ist: '' | ||
- | phpMyAdmin-Superuser ist: '' | ||
- | |||
- | ==== Debian Stretch ==== | ||
- | < | ||
- | Nach Installation der nötigen Pakete wird das Konfigurationsscript gestartet. Es konfiguriert Apache und fragt nach einem Passwort für den neu anzulegenden User '' | ||
- | <note warning> | ||
- | Auch Apache wird automatisch neu gestartet. | ||
- | <note important> | ||
- | Um dem neuen User volle Adminrechte zu gewähren: | ||
- | < | ||
software/middleware/installation.txt · Zuletzt geändert: 2024/05/03 12:52 von jau