-
Notifications
You must be signed in to change notification settings - Fork 3
Installation serveur
Mise à jour initiale du système Linux (Debian/Ubuntu):
root#> apt-get update
root#> apt-get upgrade
root#> apt-get install unzip
Ajout du repository PostgreSQL pour accéder à chaque version :
root#> nano /etc/apt/sources.list.d/pgdg.list
Exemple Ubuntu Bionic :
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
Exemple Debian Stretch :
deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main
root#> wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
root#> apt-get update
Installation de la dernière 9 (9.6). La version 10 n'est pas encore testée avec l'application :
root#> apt install postgresql-9.6
Configuration PostgreSQL (pour une instance partagée (applicatif + bdd) avec 4Go RAM) :
root#> su - postgres
postgres#> nano /etc/postgresql/9.6/main/conf.d/postgresql_user.conf
listen_addresses = '*'
autovacuum = on
shared_buffers = 1024MB
work_mem = 512MB
Gestion des accès / Sécurité :
postgres#> nano /etc/postgresql/9.6/main/pg_hba.conf
host all postgres 127.0.0.1/32 md5
host all postgres your_ip_public/32 md5
host smarthome smarthome 127.0.0.1/32 md5
postgres#> psql
postgres#> ALTER USER postgres WITH PASSWORD 'type-password';
postgres#> CREATE ROLE smarthome LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
postgres#> ALTER USER smarthome WITH PASSWORD 'type-password';
Redémarrage complet service pour tenir compte des modifs (en root !) :
root#> service postgresql restart
root#> apt-key adv --keyserver "hkps://keys.openpgp.org" --recv-keys "0x0A9AF2115F4687BD29803A206B73A36E6026DFCA"
root#> sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang deb https://dl.bintray.com/rabbitmq/debian bionic main EOF
root#> apt-get update
root#> apt-get install rabbitmq-server
root#> rabbitmq-plugins enable rabbitmq_management
Version 8
root#> mkdir /opt/java
root#> cd /opt/java
root#> wget https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz -O jdk-8u201-linux-x64.tar.gz
root#> tar -xzvf jdk-8u201-linux-x64.tar.gz
Version 2.4.4
root#> wget "https://github-production-release-asset-2e65be.s3.amazonaws.com/512295/04900416-9d8c-11e4-8842-b02070da0689?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190202%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190202T111707Z&X-Amz-Expires=300&X-Amz-Signature=bfd535d0ba765ab8c009bcc603d94bb264874905e3da879f6367e1dd7e46bc0f&X-Amz-SignedHeaders=host&actor_id=3384037&response-content-disposition=attachment%3B%20filename%3Dgrails-2.4.4.zip&response-content-type=application%2Foctet-stream" -O grails-2.4.4.zip
root#> unzip grails-2.4.4.zip
Il faut patcher le framework Grails car l'agent springloaded par défaut n'est pas compatible avec JDK 8 (ca déclenche une erreur du type : cannot copy a non-root method). Installer une version plus récente (> 1.2.1) dans le dossier grails-2.4.4/lib/org.springframework/springloaded/jars. (remplacer les fichiers et archiver les anciens)
Copier la dernière version de la lib depuis le repo Spring (avec source/javadoc) : https://repo.spring.io/libs-release-local/org/springframework/springloaded/
root#> cd grails-2.4.4/lib/org.springframework/springloaded/jars/
root#> wget https://repo.spring.io/libs-release-local/org/springframework/springloaded/1.2.8.RELEASE/springloaded-1.2.8.RELEASE.jar -O springloaded-1.2.8.RELEASE.jar
root#> wget https://repo.spring.io/libs-release-local/org/springframework/springloaded/1.2.8.RELEASE/springloaded-1.2.8.RELEASE-sources.jar -O springloaded-1.2.8.RELEASE-sources.jar
root#> wget https://repo.spring.io/libs-release-local/org/springframework/springloaded/1.2.8.RELEASE/springloaded-1.2.8.RELEASE-javadoc.jar -O springloaded-1.2.8.RELEASE-javadoc.jar
root#> mv springloaded-1.2.1.RELEASE.jar springloaded-1.2.1.RELEASE.jar.old
root#> mv springloaded-1.2.1.RELEASE-javadoc.jar springloaded-1.2.1.RELEASE-javadoc.jar.old
root#> mv springloaded-1.2.1.RELEASE-sources.jar springloaded-1.2.1.RELEASE-sources.jar.old
root#> cp springloaded-1.2.8.RELEASE.jar springloaded-1.2.1.RELEASE.jar
root#> cp springloaded-1.2.8.RELEASE-javadoc.jar springloaded-1.2.1.RELEASE-javadoc.jar
root#> cp springloaded-1.2.8.RELEASE-sources.jar springloaded-1.2.1.RELEASE-sources.jar
root#> cd /opt/java
root#> git clone https://github.com/gelleouet/smarthome-application.git smarthome-application
Compilation du projet (jdk 8 + grails 2.4.4) et création de la webapp (war)
root#> cd /opt/java/smarthome-application
root#> export JAVA_HOME=/opt/java/jdk1.8.0_201/
root#> export GRAILS_HOME=/opt/java/grails-2.4.4/
root#> export PATH=$PATH:$GRAILS_HOME/bin
root#> grails war
Version 9
root#> cd /opt/java
root#> wget http://apache.mediamirrors.org/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.tar.gz -O apache-tomcat-9.0.14.tar.gz
root#> tar -xzvf apache-tomcat-9.0.14.tar.gz
Installation du template Tomcat9-smarthome. Attention ce repo est privé car il contient certains mots de passe
root#> git clone https://github.com/gelleouet/smarthome-tomcat9.git smarthome-tomcat9
Création d'une instance tomcat nommée "bmhs" (ex n° 1 .. N). Les ports et la config sont modifiés en fonction du n° :
root#> mkdir instances
root#> /opt/java/smarthome-tomcat9/bin/deploy.sh smarthome-application-X.Y.war 1
Ajout des DNS pour connexion à la base et au serveur RabbitMQ :
root#> nano /etc/hosts
127.0.0.1 rabbitmq.smarthome postgresql.smarthome
Démarrage de l'instance créée :
root#> /opt/java/instances/bmhs-1-start.sh
Apache HTTP Server
root#> apt-get install apache2
Actions des modules
root#> a2enmod proxy_wstunnel
root#> a2enmod ssl
root#> a2enmod proxy_balancer
root#> a2enmod proxy_http
root#> a2enmod proxy_ajp
root#> a2enmod lbmethod_byrequests
Création du virtual host pour l'application BMHS
root#> nano /etc/apache2/sites-enabled/bmhs.conf
ProxyPreserveHost On
ProxyRequests off
<VirtualHost *:80>
ServerName www.domain.ext
ServerAlias domain.ext
Redirect permanent /smarthome https://www.domain.ext/smarthome
</VirtualHost>
<VirtualHost *:443>
ServerName www.srv3.consometers.org
ServerAlias srv3.consometers.org
SSLEngine On
SSLProxyEngine on
SSLCertificateFile domain.ext.crt
SSLCertificateKeyFile domain.ext.key
SSLCertificateChainFile domain.ext.pem
SSLCipherSuite HIGH:MEDIUM:!ADH:!DSS:!SSLv2:@STRENGTH:+3DES
SSLProtocol all -SSLv2 -SSLv3
ProxyPass /smarthome/websocket balancer://smarthome-websocket/smarthome/websocket
ProxyPassReverse /smarthome/websocket balancer://smarthome-websocket/smarthome/websocket
ProxyPass /smarthome/shell-endpoint balancer://smarthome-websocket/smarthome/shell-endpoint
ProxyPassReverse /smarthome/shell-endpoint balancer://smarthome-websocket/smarthome/shell-endpoint
ProxyPass /smarthome/teleinfo-endpoint balancer://smarthome-websocket/smarthome/teleinfo-endpoint
ProxyPassReverse /smarthome/teleinfo-endpoint balancer://smarthome-websocket/smarthome/teleinfo-endpoint
ProxyPass /smarthome balancer://smarthome/smarthome
ProxyPassReverse /smarthome balancer://smarthome/smarthome
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Deny from all
Allow from [yourip]
</Location>
</VirtualHost>
<Proxy balancer://smarthome-websocket>
BalancerMember ws://localhost:18080
#insert here new smarthome-websocket#
Allow from all
</Proxy>
<Proxy balancer://smarthome>
BalancerMember ajp://localhost:18009
#insert here new smarthome#
Allow from all
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</Proxy>
Redémarrage du service apache
root#> service apache2 restart