Install AirSonic on Debian/Ubuntu 🌱

What is AirSonic

Airsonic is a free, web-based media streamer, providing ubiquitous access to your music. Use it to share your music with friends, or to listen to your own music while at work. You can stream to multiple players simultaneously, for instance to one player in your kitchen and another in your living room. -https://airsonic.github.io/
  1. Log into the Linux device
  2. Run the following commands in a terminal window:
    # update software repositories
    sudo apt update
    # install openjdk
    sudo apt install default-jdk -y
    # set java-home
    sudo update-alternatives --config java
    # 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 tomcat 9
    sudo tar xzvf apache-tomcat-9*tar.gz -C /var/lib/tomcat9 --strip-components=1
    # create directories and set permissions
    sudo mkdir /var/airsonic/
    sudo chown -R tomcat:tomcat /var/airsonic/
    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]
    ReadWritePaths=/var/airsonic/
    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:

Install AirSonic

  1. Continue with the following commands in terminal:
  2. Back in the web browser, navigate to http://DNSorIP:8080/airsonic
  3. Login to AirSonic with username admin and password admin
  4. Welcome to AirSonic
  5. Click the Change administrator password link
  6. Check the Change password box
  7. Input the new password twice and click the Save button

Source: https://airsonic.github.io/docs/install/war-tomcat/