Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
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 Raspbian Stretch!)
- Doctrine 2.5
- MySQL, MariaDB, PostgreSQL oder SQLite + PDO Treiber
- APC (optional, aber empfohlen)
- jpGraph (optional, zum Plotten von PNG Grafiken)
- Apache mod_rewrite (optional)
Es eigenen sich hier Debian oder Ubuntu, sowie für den Raspberry Pi: Raspbian oder Raspbian Light.(„Buster“-Version, oder „Stretch“ mit PHP Update)
Die Abhängigkeiten lassen sich schnell mit folgendem Befehl installieren:
sudo apt-get install git-core libapache2-mod-php7.1 php7.1-cli php7.1-mysql php-apcu mysql-server mysql-client php7.1-xml php-mbstring ca-certificates apache2
bzw. für PostgreSQL
apt-get install git-core libapache2-mod-php7.1 php7.1-cli php7.1-pgsql php-apcu postgresql-8.4
Für die manuelle Installation wird zudem „curl“ benötigt.
Vollautomatisiert mit Ansible und DebOps
Siehe hierzu debops-contrib.volkszaehler.
Install-Skript (empfohlene Installationsmethode)
wget https://raw.github.com/volkszaehler/volkszaehler.org/master/bin/install.sh
bash install.sh
Das sollte dann ablaufen:
pi@raspberrypi:~ $ bash install.sh volkszaehler.org installation script checking prerequisites: php: /usr/bin/php mysql: /usr/bin/mysql awk: /usr/bin/awk sed: /bin/sed grep: /bin/grep wget: /usr/bin/wget mktemp: /bin/mktemp mkdir: /bin/mkdir git: /usr/bin/git checking php version: 7.0.19-1 >= 7.0, ok volkszaehler setup... volkszaehler path? [/home/pi/volkszaehler.org] git clone volkszaehler.org into /home/pi/volkszaehler.org Cloning into '/home/pi/volkszaehler.org'... remote: Counting objects: 11087, done. remote: Compressing objects: 100% (11/11), done. remote: Total 11087 (delta 5), reused 9 (delta 3), pack-reused 11073 Receiving objects: 100% (11087/11087), 7.19 MiB | 2.61 MiB/s, done. Resolving deltas: 100% (6085/6085), done. link from webserver to volkszaehler directory? [/var/www/volkszaehler.org] linking /var/www/volkszaehler.org to /home/pi/volkszaehler.org checking composer... /home/pi/volkszaehler.org /home/pi composer not found, downloading... All settings correct for using Composer Downloading... Composer (version 1.5.2) successfully installed to: /var/www/volkszaehler.org/composer.phar Use it: php composer.phar /home/pi composer: /home/pi/volkszaehler.org/composer.phar installing dependencies... /home/pi/volkszaehler.org /home/pi Loading composer repositories with package information Updating dependencies Package operations: 40 installs, 0 updates, 0 removals - Installing psr/log (1.0.2): Downloading (100%) - Installing symfony/debug (v3.3.9): Downloading (100%) - Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%) - Installing symfony/console (v3.3.9): Downloading (100%) - Installing doctrine/lexer (v1.0.1): Downloading (100%) - Installing doctrine/inflector (v1.2.0): Downloading (100%) - Installing doctrine/collections (v1.4.0): Downloading (100%) - Installing doctrine/cache (v1.6.2): Downloading (100%) - Installing doctrine/annotations (v1.4.0): Downloading (100%) - Installing doctrine/common (v2.7.3): Downloading (100%) - Installing doctrine/dbal (v2.5.13): Downloading (100%) - Installing andig/dbcopy (dev-master 94a72ce): Cloning 94a72ce582 from cache - Installing symfony/routing (v3.3.9): Downloading (100%) - Installing symfony/http-foundation (v3.3.9): Downloading (100%) - Installing react/promise (v2.5.1): Downloading (100%) - Installing evenement/evenement (v2.0.0): Downloading (100%) - Installing react/stream (v0.4.6): Downloading (100%) - Installing react/event-loop (v0.4.3): Downloading (100%) - Installing react/socket (v0.5.1): Downloading (100%) - Installing psr/http-message (1.0.1): Downloading (100%) - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%) - Installing ratchet/rfc6455 (v0.2.3): Downloading (100%) - Installing cboden/ratchet (v0.4): Downloading (100%) - Installing react/promise-stream (v0.1.1): Downloading (100%) - Installing ringcentral/psr7 (1.2.1): Downloading (100%) - Installing react/http (dev-master cd15204): Cloning cd15204bd1 from cache - Installing paragonie/random_compat (v2.0.11): Downloading (100%) - Installing monolog/monolog (1.23.0): Downloading (100%) - Installing react/promise-timer (v1.2.0): Downloading (100%) - Installing react/cache (v0.4.1): Downloading (100%) - Installing react/dns (v0.4.11): Downloading (100%) - Installing react/socket-client (v0.5.3): Downloading (100%) - Installing symfony/process (v3.3.9): Downloading (100%) - Installing mkraemer/react-pcntl (v2.0.0): Downloading (100%) - Installing php-pm/php-pm (dev-master 5a883f4): Cloning 5a883f48f0 from cache - Installing symfony/event-dispatcher (v3.3.9): Downloading (100%) - Installing symfony/http-kernel (v3.3.9): Downloading (100%) - Installing php-pm/httpkernel-adapter (dev-master b373b03): Cloning b373b0384f from cache - Installing doctrine/instantiator (1.0.5): Downloading (100%) - Installing doctrine/orm (v2.5.11): Downloading (100%) Writing lock file Generating autoload files install server-side graph generation (jpgraph, not required for frontend)? [n] /home/pi volkszaehler.org is not configured yet. creating new config from sample config file. mysql admin user? [root] mysql admin password? [] raspberry mysql database? [volkszaehler] mysql user? [vz] mysql password? [demo] mysql admin to volkszaehler datdabase? [vz-admin] mysql admin password? [secure] create volkszaehler.org database and admin user? [y] creating database volkszaehler... ATTENTION: This operation should not be executed in a production environment. creating db user vz-admin... Creating database schema... /home/pi/volkszaehler.org /home/pi Processing entity "Volkszaehler\Model\Aggregate" Processing entity "Volkszaehler\Model\Entity" Processing entity "Volkszaehler\Model\Channel" Processing entity "Volkszaehler\Model\Data" Processing entity "Volkszaehler\Model\Property" Processing entity "Volkszaehler\Model\Aggregator" Database schema created successfully! Proxy classes generated to "/home/pi/volkszaehler.org/lib/Model/Proxy" /home/pi 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.
Apache unter Debian "Wheezy" konfigurieren
- mod_rewrite aktivieren:
sudo a2enmod rewrite
- Default VirtualHost bearbeiten ( die Datei: „000-default“ bearbeiten):
sudo nano /etc/apache2/sites-enabled/000-default
- In der Datei, neben: < DocumentRoot > :
/var/www/volkszaehler.org/htdocs/
eintragen.
- unter <Directory /var/www/>: (Achtung <Directory> taucht öfter auf.)
neben: <AllowOverride>
FileInfo Limit Options Indexes Authconfig
eintragen. Das „none“ wird überschrieben.
Die Datei sollte dann so aussehen:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/volkszaehler.org/htdocs/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride FileInfo Limit Options Indexes AuthConfig Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Apache unter Debian "Jessie" und "Stretch" konfigurieren
- mod_rewrite aktivieren:
sudo a2enmod rewrite
- Default VirtualHost bearbeiten ( die Datei: „000-default.conf“ bearbeiten):
sudo nano /etc/apache2/sites-enabled/000-default.conf
- In der Datei, neben: < DocumentRoot > :
/var/www/volkszaehler.org/htdocs/
eintragen.
Nach dem editieren und abspeichern der Datei:
sudo systemctl restart apache2
ausführen.
Sollte es zu einem PHP Fehler beim Anlegen der Datenbank kommen versucht mal Doctrine per Hand zu Installieren.
Manuelle Installation
Download der volkszaehler.org Skripte
Download der Skripte aus dem git Repository:
git clone git://github.com/volkszaehler/volkszaehler.org.git ~/volkszaehler.org sudo ln -sf ~/volkszaehler.org /var/www/volkszaehler.org sudo chown -R www-data /var/www/volkszaehler.org
Apache konfigurieren
- mod_rewrite aktivieren:
sudo a2enmod rewrite
- Default VirtualHost bearbeiten:
/etc/apache2/sites-enabled/000-default: DocumentRoot /var/www/volkszaehler.org/htdocs/
- unter <Directory /var/www/>:
AllowOverride FileInfo Limit Options Indexes Authconfig
Alternativ: nginx konfigurieren
server { listen 80; listen [::]:80; server_name volkszaehler.org; root /var/www/volkszaehler.org/htdocs; index index.php index.html; location / { try_files $uri $uri/ =404; } location ~ \.php { include snippets/fastcgi-php.conf; # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; } }
Wichtig ist dass in der config in der Zeile „location ~ \.php {“ kein $-Zeichen hinter dem PHP steht. Siehe Mail Archiv
Installation der benötigten Module
Zunächst PHP Paketmanager Composer von getcomposer.org installieren
cd /tmp curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer sudo chmod +x /usr/local/bin/composer
Ahängigkeiten laden und installieren (v.a. Doctrine)
cd /var/www/volkszaehler.org/ # Anmerkung: ansonsten wird die Datei "composer.json" nicht gefunden; Fehlermeldung: "Composer could not find a composer.json file..." composer install
Konfiguration der Middleware
cd /var/www/volkszaehler.org/etc/ cp volkszaehler.conf.template.php volkszaehler.conf.php edit volkszaehler.conf.php: $config['db']['host'] = 'localhost'; $config['db']['user'] = 'vz'; $config['db']['password'] = '<shhh!>'; $config['db']['dbname'] = 'volkszaehler';
Alternativ wird die Installation in der Doctrine Dokumentation beschrieben. Falls du also Probleme bei der Installation haben solltest, kannst du dir hier noch ein paar Informationen holen.
Datenbank konfigurieren
- Datenbank-User anlegen:
phpmyadmin: Home -> "Rechte" -> "Neuen Benutzer hinzufügen" Benutzername: vz Host: localhost Passwort: <shhh!> keine globalen Rechte vergeben! -> ok oder: CREATE USER 'vz'@'localhost' IDENTIFIED BY '<shhhh!>';
- Datenbank anlegen:
phpmyadmin Home -> "Datenbank anlegen", Name: "volkszaehler" -> "Anlegen" oder: CREATE DATABASE `volkszaehler`;
- Tabellen anlegen:
# cd /var/www/volkszaehler.org/ # php bin/doctrine orm:schema-tool:create ATTENTION: This operation should not be executed in a production environment. Creating database schema... Database schema created successfully!
- Demoinhalte importieren:
Tabelle "entities" auswählen (unbedingt zuerst diese importieren!) "Importieren"; das Gleiche mit "properties" und "data"
oder:
cd /var/www/volkszaehler.org/misc/sql cat entities.sql properties.sql data-demoset1.sql | mysql -uroot volkszaehler -p
- Rechte setzen:
Datenbank "mysql", Tabelle "tables_priv": "Einfügen": Host: "localhost" Db: "volkszaehler" User: "vz" Table_name: "data" (anschließend das Gleiche mit "entities", "entities_in_aggregator", "properties", "tokens" Table_priv: "select", "update" und "insert" oder: GRANT select, update, insert ON volkszaehler.* TO vz@localhost;
- Nun noch ein Passwort für den mysql-Administrator „root“ setzen und die Passwortdatenbank aktivieren:
mysqladmin password -u root "<neues, gutes passwort>" mysqladmin reload -p
Aktualisierung der Middleware einschließlich des Frontends
Nachdem Volkszähler im Zuge der Installation eine Kopie des git Repositories erstellt, kann die Installation auch aus diesem Repository aktualisiert werden.
Eine Beschreibung findet sich im Kapitel zu git.
phpMyAdmin installieren
vz-admin
. Standardpasswort: secure
MySQL-Superuser ist: root
und das Standardpasswort: raspberry
phpMyAdmin-Superuser ist: phpmyadmin
und das Standardpasswort: raspberry
Debian Stretch
sudo apt-get install phpmyadmin
Nach Installation der nötigen Pakete wird das Konfigurationsscript gestartet. Es konfiguriert Apache und fragt nach einem Passwort für den neu anzulegenden User phpmyadmin
.
Auch Apache wird automatisch neu gestartet.
root
anmelden wenn man lokal als root agiert (sudo
).Von und für phpMyAdmin ist deswegen der User
phpmyadmin
angelegt worden.
Um dem neuen User volle Adminrechte zu gewähren:
sudo mysql -uroot -praspberry --execute "grant all privileges on *.* to 'phpmyadmin'@'localhost' with grant option"
Debian Jessie
sudo apt-get install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/sites-enabled/phpmyadmin.conf
sudo systemctl restart apache2
Debian Wheezy
sudo apt-get install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 reload