From 06b230d135c7ac1d449d02a7f1c648b5b3211109 Mon Sep 17 00:00:00 2001 From: nova Date: Sat, 30 May 2020 16:11:55 +0000 Subject: [PATCH] --- Installation.md | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Installation.md diff --git a/Installation.md b/Installation.md new file mode 100644 index 0000000..d526c67 --- /dev/null +++ b/Installation.md @@ -0,0 +1,110 @@ +## Installation + +To begin with, you will need the compiled jar file. You can either download it from the [release](https://git.arcusiridis.com/nova/Chatto/releases) releases section of this repo, or by building it from source. + +On linux systems, place the jar file in a directory such as /var/lib/chatto or /var/www/chatto. + +Place the below application.properties config file in the same directory - + +```properties +chatto.datasource.username = chatto_user +chatto.datasource.password = test +chatto.datasource.database-name = chatto_db +chatto.datasource.url=localhost +chatto.datasource.port=3306 +chatto.datasource.params=useSSL=false +``` + +Then you would need to configure a reverse proxy, preferably with SSL. You can obtain a free SSL certificate from letsencrypt (be sure to donate if possible). Below is a sample nginx config - + +```nginx +upstream chat { + server 127.0.0.1:8080; +} + +# Expires map +map $sent_http_content_type $expires { + default off; + text/html epoch; + text/css max; + application/javascript max; + ~image/ max; +} +server { + server_name chat.example.com; + access_log off; + error_log off; + + expires $expires; + + location / { + proxy_pass http://localhost:8080; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + } + + + #listen [::]:443 ssl ipv6only=on; # managed by Certbot + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + + +} + + +server { + if ($host = chat.example.com) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + if ($host = www.chat.example.com) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80 ; + listen [::]:80; + server_name chat.example.com; + return 404; # managed by Certbot +} +``` +Place the file in ```bash /etc/nginx/sites-available/``` (depending on your linux distro this may differ). + +Now make a symlink - ```bash sudo ln -s /etc/nginx/sites-available/chatto /nginx/sites-enabled +verify configration - ```bash sudo nginx -t``` +and restart nginx - ``` sudo systemctl restart nginx``` + +Now create a linux user - +```bash sudo useradd -r -s /bin/false``` + +Next create a systemd script making use of the created user- +``` +[Unit] +Description=System Daemon for Chatto + +[Service] +WorkingDirectory=/path/to/chatto-jar/ +ExecStart=java -jar Chatto.jar --spring.profiles.active=prod +User=chatto +Type=simple +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target +``` +Take note of the spring profiles argument. It enabled the production profile. Omitting it would run the app in dev profile. + +Name the file chatto.service and place it in ```/etc/systemd/systemd```. + +Reload systemd daemon - ```bash sudo systemctl daemon-reload``` +Then start the service - ```bash sudo systemctl start chatto``` + +If everything went well then the app should start. +Check with ```bash sudo systemctl status chatto``` and if it fails to start do ```sudo journalctl -u chatto```