Host Your Own draw.io, Visio style diagram maker

What is Draw.io?

draw.io is a configurable diagramming/whiteboarding visualization application. -https://github.com/jgraph/drawio

Install Apache Tomcat

  1. Log into the Linux device
  2. Run the following commands in a terminal:
    # check for and install software updates
    sudo apt update
    sudo apt upgrade
    # install java jdk
    sudo apt install default-jdk
    # create tomcat group and user
    sudo mkdir /var/lib/tomcat9
    sudo groupadd tomcat
    sudo useradd -s /bin/false -g tomcat -d /var/lib/tomcat9 tomcat
    # lookup the latest tomcat 9 release
    regex='<a href="v[^/]*\/">v([^/]*)\/<\/a>' && response=$(curl -s https://downloads.apache.org/tomcat/tomcat-9/?C=M;O=D) && [[ $response =~ $regex ]] && downloadURL="${BASH_REMATCH[1]}"
    # download tomcat 9
    curl -O https://downloads.apache.org/tomcat/tomcat-9/v$downloadURL/bin/apache-tomcat-$downloadURL.tar.gz
    # extract the download
    sudo tar xzvf apache-tomcat-9*tar.gz -C /var/lib/tomcat9 --strip-components=1
    # set permissions
    cd /var/lib/tomcat9
    sudo chgrp -R tomcat /var/lib/tomcat9
    sudo chmod -R g+r conf
    sudo chmod g+x conf
    sudo chown -R tomcat webapps/ work/ temp/ logs/
    # run tomcat as a service
    sudo update-java-alternatives -l
    sudo nano /etc/systemd/system/tomcat.service
  3. Paste the following configuration into tomcat.service

    [Unit]
    Description=Apache Tomcat
    After=network.target

    [Service]
    Type=forking

    Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
    Environment=CATALINA_PID=/var/lib/tomcat9/temp/tomcat.pid
    Environment=CATALINA_HOME=/var/lib/tomcat9
    Environment=CATALINA_BASE=/var/lib/tomcat9
    Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
    Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

    ExecStart=/var/lib/tomcat9/bin/startup.sh
    ExecStop=/var/lib/tomcat9/bin/shutdown.sh

    User=tomcat
    Group=tomcat
    UMask=0007
    RestartSec=10
    Restart=always

    [Install]
    WantedBy=multi-user.target

  4. Continue with the following commands in terminal:
    sudo systemctl daemon-reload
    sudo systemctl start tomcat
    sudo systemctl status tomcat
    sudo systemctl enable tomcat
  5. Open a browser and navigate to http://DNSorIP:8080 to test that Tomcat is installed and running

Installing jGraph/mxGraph from draw.io

  1. Run the following commands in terminal:
    # download the draw.war file
    cd ~
    wget https://github.com/jgraph/drawio/releases/download/v13.8.0/draw.war
    # copy draw.war to the tomcat webapps directory
    sudo cp ./draw.war /var/lib/tomcat9/webapps
  2. Back in the browser, navigate to http://DNSorIP:8080/draw
  3. Enjoy a self-hosted diagram creation studio in your web browser

Source: https://github.com/jgraph/drawio