diff --git a/docs/INSTALL.MD b/docs/INSTALL.MD new file mode 100644 index 0000000..16d47fc --- /dev/null +++ b/docs/INSTALL.MD @@ -0,0 +1,95 @@ +# Installation + +## Rust +```bash +# Download & install rust +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +``` + +## Comunic Server +1. Clone the repository +```bash +git clone https://gitlab.com/comunic/comunicapiv3 +cd comunicapiv3 +``` + +2. Build the server +```bash +cargo build --release +``` + +3. Create & edit custom configuration +```bash +cp config.yaml config.private.yaml +chmod 700 config.private.yaml +nano config.private.yaml +``` + +4. Adapt the following command to test the server: `/home/comunic/comunicapiv3/target/release/comunic_server /home/comunic/comunicapiv3/config.private.yaml` + +5. Enable required modules in Apache: +```bash +sudo a2enmod proxy_http +sudo a2enmod proxy_wstunnel +``` + +6. Create Apache configuration, save it & restart Apache: +```conf + + ServerName api.communiquons.org + + ServerAdmin webmaster@localhost + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # Redirect user web socket + RewriteEngine On + RewriteCond %{REQUEST_URI} (.*)/ws$ [NC] + RewriteRule /ws ws://localhost:3005/ws [P,L] + + + ProxyPreserveHost On + ProxyRequests off + AllowEncodedSlashes NoDecode + ProxyPass / http://localhost:3005/ nocanon + ProxyPassReverse / http://localhost:3005/ + + SSLEngine on + SSLCertificateFile /etc/letsencrypt/live/communiquons.org-0001/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/communiquons.org-0001/privkey.pem + +``` + +7. Create systemd configuration (in `/etc/systemd/system/comunic.service`): +```conf +[Unit] +Description=Comunic API Server +After=syslog.target +After=network.target + +[Service] +# Modify these two values ​​and uncomment them if you have +# repos with lots of files and get to HTTP error 500 because of that +### +# LimitMEMLOCK=infinity +# LimitNOFILE=65535 +RestartSec=2s +Type=simple +User=comunic +Group=comunic +WorkingDirectory=/home/comunic +ExecStart=/home/comunic/comunicapiv3/target/release/comunic_server /home/comunic/comunicapiv3/config.private.yaml +Restart=always +Environment=USER=comunic +HOME=/home/comunic + +[Install] +WantedBy=multi-user.target +``` + +8. Enable new configuration: +```bash +sudo systemctl enable comunic.service +sudo systemctl start comunic.service +```