1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-25 14:59:21 +00:00
comunicapiv3/docs/INSTALL.MD

2.2 KiB
Raw Blame History

Installation

Rust

# Download & install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Comunic Server

  1. Clone the repository
git clone https://gitlab.com/comunic/comunicapiv3
cd comunicapiv3
  1. Build the server
cargo build --release
  1. Create & edit custom configuration
cp config.yaml config.private.yaml
chmod 700 config.private.yaml
nano config.private.yaml
  1. Adapt the following command to test the server: /home/comunic/comunicapiv3/target/release/comunic_server /home/comunic/comunicapiv3/config.private.yaml

  2. Enable required modules in Apache:

sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
  1. Create Apache configuration, save it & restart Apache:
<VirtualHost *:443>
    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
</VirtualHost>
  1. Create systemd configuration (in /etc/systemd/system/comunic.service):
[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
  1. Enable new configuration:
sudo systemctl enable comunic.service
sudo systemctl start comunic.service