How To Install Airsonic Media Server On an Ubuntu 18.04 VPS or Dedicated Server

Introduction

Airsonic is an open-source media server that allows you to fully access your music and share it with colleagues or even enjoy listening to your favorite playlist at any place. This free self-hosted media streamer is based on Java language, and built to deal with a large collection of music and is the ultimate solution for MP3 streaming. Airsonic is compatible with any video or audio file format as long as they are streaming comfortably over HyperText Transfer protocol including FLAX, WMA, APE, and many more. In this article, we will take you through the process of installing Airsonic on your Ubuntu 18.04 server. Similarly, we will also install Airsonic with the help of the reliable.WAR package, activate the service, then configure Nginx server as a reverse proxy for this installation.

Before You Start

With these items in place, let’s get started.

Step 1 –
Installing Java OpenJDK

Being a java language based app, Airsonic needs to use Java for the installation process. This process requires the installation of the latest  OpenJDK series. First, start by installing Java OpenJDK. You can get it from Webupd8team; the official PPA repository. Remember to install the common packages of the software then include the PPA repository for Java OpenJDK. You can do this by running the following command:

$ sudo apt install software-properties-common apt-transport-https -y
$ sudo add-apt-repository ppa:webupd8team/java -y

The next step involves the installation of the Java OpenJDK.

$ sudo apt installoracle-java8-installer -y

The system should automatically install Java OpenJDK application on your Ubuntu 18.04 server. Once you’re done, execute the command below to check the current version of Java OpenJDK:

$ java -version

This will give you the output below:

Javaversion "1.8.0_181"
Java (TM) SERuntimeEnvironment (build 1.8.0_181-b13)
JavaHotSpot (TM) 64-BitserverVM (build 25.181-b13, mixmode)

Step 2 –
Installing and Configuring Airsonic

Airsonic can be installed in several different packages. In this article, we shall explore our stand-alone installation using WAR packages. Start by creating another user with the name ‘airsonic,’ then create a directory named ‘/opt/airsonic.’ For this process, run the following command:

$ sudo useradd airsonic
$ sudo mkdir -p /opt/airsonic

Open the newly created directory; /opt/airsonic and search then download the .WAR package for Airsonic using wget as shown below:

$ cd /opt/airsonic
$ wget https://github.com/airsonic/airsonic/releases/download/v10.1.1/airsonic.war

Change the name of this directory to ‘airsonic’ user as well as the group.

$ sudo chown -R airsonic:airsonic /opt/airsonic

After that, the .WAR package for the Airsonic installation should be downloaded. The next thing creating a new file for Airsonic. To do so, go to ‘/etc/systemd/system’ directory then create a service file named airsonic.service

$ sudo nano /etc/systemd/system

Edit and include the following lines for the Airsonic configuration as shown below:

[Unit]
Description=Airsonic Media Server
After=remote-fs.target network.target
AssertPathExists=/opt/airsonic

[Service]
Type=simple
Environment="JAVA_JAR=/opt/airsonic/airsonic.war"
Environment="JAVA_OPTS=-Xmx700m"
Environment="AIRSONIC_HOME=/opt/airsonic"
Environment="PORT=8080"
Environment="CONTEXT_PATH=/airsonic"
Environment="JAVA_ARGS="
EnvironmentFile=-/etc/sysconfig/airsonic
ExecStart=/usr/bin/java 
          $JAVA_OPTS 
          -Dairsonic.home=${AIRSONIC_HOME} 
          -Dserver.context-path=${CONTEXT_PATH} 
          -Dserver.port=${PORT} 
          -jar ${JAVA_JAR} $JAVA_ARGS
User=airsonic
Group=airsonic

[Install]
WantedBy=multi-user.target

Now save and close the file. Restart your system and go to ‘/etc/default’ directory then create a default file for airsonic.

$ sudo systemctl daemon-reload
$ sudo nano /etc/default/airsonic

Add the default configuration file below for airsonic:

# Set the location of the standalone war to use
JAVA_JAR=/opt/airsonic/airsonic.war

# Set any java opts separated by spaces
JAVA_OPTS=-Xmx700m

# Set a different location for the airsonic home.
# If this path is /opt/libresonic or even contains "libresonic",
# the data from a previous libresonic can be used as is (i.e. without
# renaming libresonic.properties,db/libresonic*, etc
AIRSONIC_HOME=/opt/airsonic

# Change the port to listen on
PORT=8080

# Change the path that is listened to on
CONTEXT_PATH=/airsonic

# Add any java args. These are different than JAVA_OPTS in that
# they are passed directly to the program. The default is empty:
#JAVA_ARGS=

# Note that there are several settings for spring boot, not explicitly listed
# here, but can be used in either JAVA_OPTS or JAVA_ARGS. The full list
# can be found here:
# https://docs.spring.io/spring-boot/docs/1.4.5.RELEASE/reference/htmlsingle/#common-application-properties
# For example to set debug across the board:
#JAVA_ARGS=--debug

# Or to change the IP address that is listened to:
JAVA_ARGS=--server.address=127.0.0.1

Now, save and close the file. Restart your Airsonic service then set it to start on boot time.

$ sudo systemctl start airsonic
$ sudo systemctl enable airsonic

Now the installation process for airsonic alone is done. Use a netstat command to check its status.

$ netstat -plntu

At this point, the default Airsonic service will listen to port ‘8080’ that is used by Airsonic’s Java service.

Step 3 –
Generating A New SSL Lets Encrypt Cert

As aforementioned, we will install Airsonic via the HTTP connections for Nginx web server, but you have to choose a domain name of your choice. Now, we will try to create the SSL certificate using Letsencrypt. First, execute the command below to install the required Letsencrypt tool:

$ sudo apt install letsencrypt -y

Once the tool is installed, you can now create a new SSL certificate for your domain name using the following command. Remember to replace the value “domian name” with your precise domain name:

$ certbot certonly --standalone -domain name

When you run the command above, you’ll be prompted to provide your email address to receive notifications. Type ‘A’ for the TOS agreement on Letsencrypt to show that you agree with the terms then type ‘N’ for No for the shared email address. Once you’re done, you will receive a congratulatory message to show that your certificate has been successfully generated and saved in the /etc/letsencrypt/live/domain directory.

Step 4 –
Installing and Configuring Nginx Reverse Proxy

Now we shall start installing the Nginx server then configure it on port 8080 on Airsonic software as a reverse proxy. To start the Nginx installation, run the apt command below:

$sudo apt install nginx -y

Now, open the ‘/etc/nginx’ directory then create a new virtual host file named ‘airsonic.’ cd /etc/nginx/

$ sudo nano  sites-available/airsonic

Add the following lines in the configuration:

server {
    listen80;
    listen [::]:80;
    server_name music.hakase-labs.io;
    # enforce https
    return301 https://$server_name$request_uri;
}

server {
    listen              443 ssl;
    server_name         music.hakase-labs.io;
    ssl_certificate /etc/letsencrypt/live/music.hakase-labs.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/music.hakase-labs.io/privkey.pem;

    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                         http://127.0.0.1:8080;
      proxy_redirect                     http:// https://;
    }
}

Now, save and close the file. The next step is to activate the already created ‘airsonic host file then start testing the configuration:

$ sudo ln -s /etc/nginx/sites-available/airsonic /etc/nginx/sites-enabled/
nginx -t

Confirm that there are no errors, then restart the Nginx service and set it to start at boot time.

$ sudo systemctl restart nginx
$ sudo systemctl enable nginx

By this point, the Nginx service is successfully operating as the reverse proxy for Airsonic. It should listen to port 8080 under a secure https connection. To confirm this, use the netstat command as shown below:

$ netstat -plntu

Step 5 –
Configuring Uncomplicated Firewall (UFW) Firewall

Here, we shall work on Ubuntu UFW firewall. Start by accessing the Uncomplicated Firewall by opening the SSH, HTTPS, and HTTP service using the commands below:

$ sudo ufw allow ssh
$ sudo ufw allow http
$ sudo ufw allow https

Go ahead and activate your ufw firewall.

$ sudo ufw enable

Now, enter ‘y’ for Yes then click Enter to complete the activation.

Step 6 –
Verifying The Installation

For this step, open your favorite web browser, then enter the URL for Airsonic installation.

https://yourdomainname/airsonic/

You should see the login page for Airsonic. How To Install Airsonic Media Server on Ubuntu 18.04 LTS Now, use the default username and password which is ‘admin,’ to log into your Airsonic dashboard. Once you access the dashboard, you can access the intuitive Airsonic dashboard. The next step is to change the default password. To do so, select Change administrator password. How To Install Airsonic Media Server on Ubuntu 18.04 LTS Choose admin user then mark the Change password checkbox before typing your new admin password. Once you’re done, select Save. How To Install Airsonic Media Server on Ubuntu 18.04 LTS Now, Airsonic initial admin password has been successfully changed. The next step is to create media folders. Setting up Medial Folders. Go to your server’s terminal shell and create media folders then label them as ‘airsonic’ user.

$ suod mkdir -p /var/music
$ sudo chown -R airsonic:airsonic /var/music

On Airsonic dashboard, select Settings then locate the Media folders icon. How To Install Airsonic Media Server on Ubuntu 18.04 LTS Ensure that your default Music media folders are activated, before pressing the Save button. Next, locate the User section then choose admin user and check the Music media folder box as shown below: How To Install Airsonic Media Server on Ubuntu 18.04 LTS Now the Music media file is enabled. Now the user can be able to access these media files. Here is how the Airsonic dashboard should look like after making the changes. How To Install Airsonic Media Server on Ubuntu 18.04 LTS

Conclusion

That is it! Airsonic has been successfully installed on your Ubuntu 18.04 server.

Check out these top 3 VPS services:

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Install Own Cloud On an an Ubuntu 18.04 Dedicated Server or VPS

You can create your own self-hosted cloud storage services by installing the ope
3 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install a Let’s Encrypt Certificate on your Ubuntu 18.04 Dedicated Server or VPS

If you are hosting your website on a VPS server running Ubuntu 18.04, we will sh
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Enable Two-Factor Authentication on an Ubuntu 18.04 VPS or Dedicated Server

This guide will show you how you enable two-factor authentication to improve the
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Harden Your Apache Web Server on an Ubuntu 18.04 Dedicated Server or VPS

Apache as one of the most popular web servers is susceptible to hacking attacks.
3 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top