Prerequisites
In order to install and run Airsonic, you will need:
Install OpenJDK 8
sudo apt-get install openjdk-8-jre sudo update-alternatives --config java
Download Airsonic WAR package
Download the latest Airsonic .war package from the download page, or with the command below:
wget https://github.com/airsonic/airsonic/releases/download/v10.6.2/airsonic.war
Download and import Andrew DeMaria
public key:
gpg --keyserver keyserver.ubuntu.com --recv 0A3F5E91F8364EDF
Download the signed checksums file and verify the previously download .war package:
wget https://github.com/airsonic/airsonic/releases/download/v10.6.2/artifacts-checksums.sha.asc gpg --verify artifacts-checksums.sha.asc sha256sum -c artifacts-checksums.sha.asc
Run Airsonic WAR package
Create the Airsonic directory and assign ownership to the user that will run Airsonic:
sudo mkdir /var/airsonic/ useradd airsonic //Now we need creat a new user "airsonic" //sudo chown -R $USER:$GROUP /var/airsonic sudo chown -R airsonic:airsonic /var/airsonic
Now you can simply run java against the airsonic.war package:
java -jar airsonic.war //Run it make sure no error happend.
Airsonic should be running at http://localhost:8080 if installed locally, replace localhost
with your server IP address if installed remotely.
Systemd
Use Systemd to boot on startup.
Download the war (Can move the file to this folder):
wget https://github.com/airsonic/airsonic/releases/download/v10.6.2/airsonic.war --output-document=/var/airsonic/airsonic.war
Setup systemd service:
wget https://raw.githubusercontent.com/airsonic/airsonic/master/contrib/airsonic.service -O /etc/default/system/airsonic.service
systemctl daemon-reload
systemctl start airsonic.service
systemctl enable airsonic.service
wget https://raw.githubusercontent.com/airsonic/airsonic/master/contrib/airsonic-systemd-env -O /etc/default/airsonic
Change airsonic.service use vi
[Unit]
Description=Airsonic Media Server
After=remote-fs.target network.target
AssertPathExists=/var/airsonic
[Service]
Type=simple
Environment="JAVA_JAR=/var/airsonic/airsonic.war"
Environment="JAVA_OPTS=-Xmx700m"
Environment="AIRSONIC_HOME=/var/airsonic"
Environment="PORT=8080"
Environment="CONTEXT_PATH=/var/airsonic/music"
Environment="JAVA_ARGS="
EnvironmentFile=-/etc/default/airsonic
ExecStart=/usr/bin/java \
$JAVA_OPTS \
-Dairsonic.home=${AIRSONIC_HOME} \
-Dserver.servlet.contextPath=${CONTEXT_PATH} \
-Dserver.port=${PORT} \
-jar ${JAVA_JAR} $JAVA_ARGS
User=airsonic
Group=airsonic
# See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
# for details
DevicePolicy=closed
DeviceAllow=char-alsa rw
NoNewPrivileges=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @privileged @reboot @setuid @swap
ReadWritePaths=/var/airsonic
# You can uncomment the following line if you're not using the jukebox
# This will prevent airsonic from accessing any real (physical) devices
#PrivateDevices=yes
# You can change the following line to `strict` instead of `full`
# if you don't want airsonic to be able to
# write anything on your filesystem outside of AIRSONIC_HOME.
ProtectSystem=full
# You can uncomment the following line if you don't have any media
# in /home/…. This will prevent airsonic from ever reading/writing anything there.
#ProtectHome=true
# You can uncomment the following line if you're not using the OpenJDK.
# This will prevent processes from having a memory zone that is both writeable
# and executeable, making hacker's lifes a bit harder.
#MemoryDenyWriteExecute=yes
[Install]
WantedBy=multi-user.target
Change airsonic use vi (Setting)
# Set the location of the standalone war to use
JAVA_JAR=/var/airsonic/airsonic.war
# Set any java opts separated by spaces
JAVA_OPTS=-Xmx700m
# Set a different location for airsonic home.
# If this path is /var/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=/var/airsonic
# Change the port to listen on
PORT=8080
# Change the path that is listened 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 on:
#JAVA_ARGS=--server.address=127.0.0.1