How to Install AirSonic on Ubuntu 18.04 LTS

Updated on October 19, 2018
How to Install AirSonic on Ubuntu 18.04 LTS header image

AirSonic is a free and open source media streaming server. In this tutorial, I will guide you through the process of deploying an AirSonic server instance from scratch on a Ubuntu 18.04 LTS server instance.


  • A newly deployed Vultr Ubuntu 18.04 LTS server instance with at least 2GB of memory. Say it has an IPv4 address
  • A sudo user.
  • A domain being pointed to the server instance mentioned above.

Step 1: Basic system configuration

Create a swap file

In order to get better system performance, it's recommended to create a 2GB (2048M) swap file on a machine with 2GB of memory:

sudo dd if=/dev/zero of=/swapfile count=2048 bs=1M
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile   none    swap    sw    0   0' | sudo tee -a /etc/fstab
free -m

Note: If you are using a different server size, the suitable size of the swap partition may vary.

Setup the machine's hostname and fully qualified domain name (FQDN)

Properly setting up a hostname and an FQDN for the machine is required for enabling HTTPS security with a Let's Encrypt SSL certificate.

The following commands will setup a hostname airsonic and an FQDN for the machine:

sudo hostnamectl set-hostname airsonic
sudo sed -i 's/^*$/ airsonic/g' /etc/hosts

The results can be confirmed with the following:

hostname -f

Modify firewall rules in order to allow inbound SSH, HTTP, and HTTPS traffic

Setup UFW firewall rules for running an AirSonic server:

sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https
sudo ufw enable

When you see the prompt Command may disrupt existing ssh connections. Proceed with operation (y|n)?, input y and then press Enter.

Update the system

For security and performance purposes, it's necessary to update the Ubuntu 18.04 LTS system to the latest status:

sudo apt update
sudo apt upgrade -y && sudo shutdown -r now

During the upgrade, you may be informed that the currently installed version of grub configuration file has been locally modified. Since we are not actually responsible for the modification, use the Up arrow to highlight the install the package maintainer's version option, and then press Enter.

After the system reboots, log back in as the same sudo user to move on.

Step 2: Install OpenJDK Java Runtime Environment (JRE) 8

Install OpenJDK JRE 8 and then confirm the results:

sudo apt install -y openjdk-8-jre-headless
java -version

The output of the second command will be similar to the following:

openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

In addition, you need to setup the JAVA_HOME environment variable as follows:

echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile
source /etc/profile

Step 3: Install AirSonic

AirSonic can be deployed using various methods. In this tutorial, we will install AirSonic using the AirSonic WAR package.

Create a dedicated user and a dedicated group, both named airsonic:

sudo groupadd airsonic
sudo mkdir /var/airsonic
sudo useradd -s /bin/nologin -g airsonic -d /var/airsonic -M airsonic

Download the latest AirSonic WAR package, AirSonic v10.1.2:

cd /var/airsonic
sudo wget
sudo chown -R airsonic:airsonic /var/airsonic

Download the predefined AirSonic systemd unit files and then start the AirSonic service:

sudo wget -O /etc/systemd/system/airsonic.service
sudo wget -O /etc/default/airsonic
sudo systemctl daemon-reload
sudo systemctl start airsonic.service
sudo systemctl enable airsonic.service

Note: You may need to review and customize the two AirSonic systemd unit files on your own machine.

Step 4: Test the installation

AirSonic will be up and running now, listening on port 8080. You can use the following command to confirm that this is the case:

ps -ef|grep airsonic

You can also directly visit the AirSonic site, but you need to temporarily modify firewall rules first:

sudo ufw allow in 8080/tcp

Next, point your favorite web browser to, and then use the default credentials listed below to log in:

  • Username: admin
  • Password: admin

For security purposes, you should change the administrator's password immediately after logging in.

Once the result is confirmed, restrict access on port 8080 again:

sudo ufw deny in 8080/tcp

Step 5: Obtain a Let's Encrypt SSL certificate for your AirSonic site

For security purposes, it's recommended to enable HTTPS security on every newly created website. The most convenient practice for that is to deploy a Let's Encrypt SSL certificate as follows.

Install the Certbot utility:

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:certbot/certbot
sudo apt update
sudo apt install -y certbot

Use Certbot to apply for a Let's Encrypt SSL certificate for the domain

sudo certbot certonly --standalone --agree-tos --no-eff-email -m -d

The certificate and chain will be saved at the following:


The key file will be saved here:


The Let's Encrypt SSL certificate is designed to expire in three months. You can setup a cron job to renew your certificates automatically:

sudo crontab -e

When you are prompted to select an editor, input 2 and then press Enter to choose /usr/bin/vim.basic.

Next, press O, and add a new line as shown below:

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew

Save and quit:


This cron job will attempt to update the Let's Encrypt certificate every day at noon.

Step 6: Install Nginx as a reverse proxy

With the help of Nginx, you can both facilitate visitors' access, (so that they no longer need to input the 8080 port number), and enable HTTPS security on your AirSonic website.

Install Nginx using APT:

sudo apt install -y nginx

Next, create a config file for AirSonic:

cat <<EOF | sudo tee /etc/nginx/sites-available/airsonic.conf
# Redirect HTTP to HTTPS
server {
    listen      80;
    return      301 https://\$server_name\$request_uri;

server {

    # Setup HTTPS certificates
    listen       443 default ssl;
    ssl_certificate      /etc/letsencrypt/live/;
    ssl_certificate_key  /etc/letsencrypt/live/;

    # Proxy to the Airsonic server
    location /airsonic {
        proxy_set_header X-Real-IP         \$remote_addr;
        proxy_set_header X-Forwarded-For   \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Host  \$http_host;
        proxy_set_header Host              \$http_host;
        proxy_max_temp_file_size           0;
        proxy_pass               ;
        proxy_redirect                     http:// https://;

Create a symbolic link pointing to the newly created AirSonic Nginx config file:

sudo ln -s /etc/nginx/sites-available/airsonic.conf /etc/nginx/sites-enabled/

Restart Nginx in order to put your configuration into effect:

sudo systemctl restart nginx.service
sudo systemctl enable nginx.service

Finally, point your favorite web browser to or to start exploring your AirSonic website.