nova 2020-05-30 16:11:55 +00:00
parent 1b51ab4857
commit 06b230d135

110
Installation.md Normal file

@ -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```