How to install and optimize subsonic on a Qnap NAS Server
Posted: Sun Apr 24, 2011 11:38 pm
Hello.
I've put a lot of work in installing and optimizing subsonic on a Qnap NAS linux based System. This is especially targeted at the Atom processor based models, but it should probably also work on others (but this guide is not tailored to those). My model is the Qnap TS 459 Pro which has a dual core Atom processor.
I have done this on one having a firmware version 3.4.0
By default a Qnap NAS system does not come with java and tomcat. You have to install those first.
1) Installing the basic software
* Log into your Qnap Adminstration web interface and to to Application Servers->QPKG Plugins and click on "GET QPKG". A window with a list of available packages should open.
* Select "Java Runtime Environment" and download that zip file (at the time of writing: http://eu1.qnap.com/Storage/QPKG/X86/JRE_6_X86.zip)
* Select "Tomcat" and download the zip file (at the time of writing: http://eu1.qnap.com/Storage/QPKG/X86/To ... 20_x86.zip)
* Select "Optware IPKG" and download optware (at the time of writing for intel systems: http://eu1.qnap.com/Storage/QPKG/X86/Op ... 63_x86.zip).
* Click on tab "INSTALLATION" in the main window (where you clicked GET QPKG before) and click the button to browse for a file an select the downloaded java zip file. Click INSTALL.
* You may need to reboot the NAS, not sure though. Now do the same with the downloaded tomcat zip file (brows it and click INSTALL).
* Enable tomcat by clicking on QPKG INSTALLED and then Tomcat. On the opening window click the button ENABLE.
* Install Optware: Install this package the same way as the others in the INSTALLATION tab. This allows you to install additonal linux software packages on your Qnap system. You will need it to install a usable command line text editor and transcoding software.
* Reboot your Qnap NAS.
* Go to the QPKG Plugins page again, click Tomcat and click the link beside "Web Page".
2) Configuring Tomcat and installing Subsonic
* Before installing Subsonic you should configure tomcat manager users. Do so by modifying the tomcat-users.xml file that is found on your Qnap system now. It is advisable to log in to your Qnap using ssh (i recommend Putty under windows) with your admin user. It should be located in /share/MD0_DATA/.qpkg/Tomcat/tomcat/conf/tomcat-users.xml
I find it most convenient to installing the nano console editor by typing "ipkg install nano". You need the Optware package installed for this. Also, if it does not find the command ipkg then you have to apply some fixes to the paths. See section 3) for that
Type nano <file-path> to edit the file you wish, in this case the full path to tomcat-uses.xml.
For me I have the following roles and users configured there:
(to save exit nano and save the file type ctrl-X and then Y)
* On the opened Apache Tomcat web page click on "Tomcat Manager". You will have to log in with a user you configured in your tomcat-users.xml file.
* Download the latest subsonic war release (go to http://www.subsonic.org/pages/download.jsp and click download at the "WAR version (all platforms)".
* On the Tomcat Manager page scroll down, select the war file in "select WAR file to upload" and click Deploy.
* Subsonic should not be installed and be listed in the "Applications" list. Just click the link /subsonic.
If all worked well you have now installed subsonic.
However, there is a problem on Qnap Systems. After rebooting your Qnap NAS all your subsonic settings will be gone.
This is because subsonic settings are by default stored in a place that are cleaned up on reboot.
You have to move the location to they remain permanent:
* You need to be logged in via ssh to your Qnap NAS again.
* Subsonic is installed in /var/subsonic. Copy that to /share/MD0_DATA/subsonic (/share/MD0_DATA is the location of your harddrive-array were you store all your data). To do this type cp -r /var/subsonic /share/MD0_DATA/subsonic.
* Now remove the original subsonic data by typing rm -rf /var/subsonic.
* Since subsonic will still look for the data in /var/subsonic create a symbolic link from your real new subsonic data to the one where subsonic looks by typing ln -s /share/MD0_DATA/subsonic /var/subsonic
* However, even this symbolic link will be removed upon restart. So you must instruct the system to create it once tomcat starts up if it is not there yet. The startup of tomcat is controlled with the file tomcat.sh. Open it with nano: nano /etc/init.d/tomcat.sh
* Search for the lines
case "$1" in
start)
and add the following below
* Save the file (type ctrl+X and then Y to save)
* If you have problems staring up subsonic from the tomcat manager page this may be because of the owner of subsonic. In such a case (I myself cannot remember having it), execute this command:
chown -R tomcat /share/MD0_DATA/subsonic /var/subsonic
This tip came from cxc4u, thanx for this!
3) fixing opt paths (optional, when required)
Some Qnap systems have a bug that the /opt folder is not added to the path. Here is how to modify the optware startup accordingly:
* Open Optware.sh (nano /etc/init.d/Optware.sh)
* Search for the line (you can use ctrl-W for that)
# adding Ipkg apps into system path ...
and replace it with the code below until before the lines
;;
stop)
Plase note that this code is not perfect. Currently for instance it appends to /etc/ld.so.conf creating duplicate lines with each reboot or restart of the service. You are free to suggest corrected code!
* Save the changes (ctrl-X and then Y)
* The changes only become effective either after restarting optware (/etc/init.d/Optware.sh restart) or restarting the whole NAS and loggin in with ssh again.
Now subsonic should be set up and data should be maintained.
This is the end of the basic guide. The next post will contain advanced setup so transcoding is supported and improved video streaming over the standard recommended ffmpe, using a modified build of mplayer2 that also supports encoding.
A basic instruction (that misses some details but on which I based my efforts on) can be found here: http://forum.subsonic.org/forum/viewtopic.php?t=1851
Hope this helped you get Subsonic running.
I've put a lot of work in installing and optimizing subsonic on a Qnap NAS linux based System. This is especially targeted at the Atom processor based models, but it should probably also work on others (but this guide is not tailored to those). My model is the Qnap TS 459 Pro which has a dual core Atom processor.
I have done this on one having a firmware version 3.4.0
By default a Qnap NAS system does not come with java and tomcat. You have to install those first.
1) Installing the basic software
* Log into your Qnap Adminstration web interface and to to Application Servers->QPKG Plugins and click on "GET QPKG". A window with a list of available packages should open.
* Select "Java Runtime Environment" and download that zip file (at the time of writing: http://eu1.qnap.com/Storage/QPKG/X86/JRE_6_X86.zip)
* Select "Tomcat" and download the zip file (at the time of writing: http://eu1.qnap.com/Storage/QPKG/X86/To ... 20_x86.zip)
* Select "Optware IPKG" and download optware (at the time of writing for intel systems: http://eu1.qnap.com/Storage/QPKG/X86/Op ... 63_x86.zip).
* Click on tab "INSTALLATION" in the main window (where you clicked GET QPKG before) and click the button to browse for a file an select the downloaded java zip file. Click INSTALL.
* You may need to reboot the NAS, not sure though. Now do the same with the downloaded tomcat zip file (brows it and click INSTALL).
* Enable tomcat by clicking on QPKG INSTALLED and then Tomcat. On the opening window click the button ENABLE.
* Install Optware: Install this package the same way as the others in the INSTALLATION tab. This allows you to install additonal linux software packages on your Qnap system. You will need it to install a usable command line text editor and transcoding software.
* Reboot your Qnap NAS.
* Go to the QPKG Plugins page again, click Tomcat and click the link beside "Web Page".
2) Configuring Tomcat and installing Subsonic
* Before installing Subsonic you should configure tomcat manager users. Do so by modifying the tomcat-users.xml file that is found on your Qnap system now. It is advisable to log in to your Qnap using ssh (i recommend Putty under windows) with your admin user. It should be located in /share/MD0_DATA/.qpkg/Tomcat/tomcat/conf/tomcat-users.xml
I find it most convenient to installing the nano console editor by typing "ipkg install nano". You need the Optware package installed for this. Also, if it does not find the command ipkg then you have to apply some fixes to the paths. See section 3) for that
Type nano <file-path> to edit the file you wish, in this case the full path to tomcat-uses.xml.
For me I have the following roles and users configured there:
- Code: Select all
<role rolename="tomcat"/>
<role rolename="manager"/>
<user username="tomcat" password="<password for user tomcat>" roles="tomcat"/>
<user username="admin" password="<password for user manager>" roles="manager"/>
(to save exit nano and save the file type ctrl-X and then Y)
* On the opened Apache Tomcat web page click on "Tomcat Manager". You will have to log in with a user you configured in your tomcat-users.xml file.
* Download the latest subsonic war release (go to http://www.subsonic.org/pages/download.jsp and click download at the "WAR version (all platforms)".
* On the Tomcat Manager page scroll down, select the war file in "select WAR file to upload" and click Deploy.
* Subsonic should not be installed and be listed in the "Applications" list. Just click the link /subsonic.
If all worked well you have now installed subsonic.
However, there is a problem on Qnap Systems. After rebooting your Qnap NAS all your subsonic settings will be gone.
This is because subsonic settings are by default stored in a place that are cleaned up on reboot.
You have to move the location to they remain permanent:
* You need to be logged in via ssh to your Qnap NAS again.
* Subsonic is installed in /var/subsonic. Copy that to /share/MD0_DATA/subsonic (/share/MD0_DATA is the location of your harddrive-array were you store all your data). To do this type cp -r /var/subsonic /share/MD0_DATA/subsonic.
* Now remove the original subsonic data by typing rm -rf /var/subsonic.
* Since subsonic will still look for the data in /var/subsonic create a symbolic link from your real new subsonic data to the one where subsonic looks by typing ln -s /share/MD0_DATA/subsonic /var/subsonic
* However, even this symbolic link will be removed upon restart. So you must instruct the system to create it once tomcat starts up if it is not there yet. The startup of tomcat is controlled with the file tomcat.sh. Open it with nano: nano /etc/init.d/tomcat.sh
* Search for the lines
case "$1" in
start)
and add the following below
- Code: Select all
### Create Subsonic link in /var
if [ ! -e /var/subsonic ]; then
ln -s /share/MD0_DATA/subsonic /var/subsonic
fi
### End of Subconic link creation
* Save the file (type ctrl+X and then Y to save)
* If you have problems staring up subsonic from the tomcat manager page this may be because of the owner of subsonic. In such a case (I myself cannot remember having it), execute this command:
chown -R tomcat /share/MD0_DATA/subsonic /var/subsonic
This tip came from cxc4u, thanx for this!
3) fixing opt paths (optional, when required)
Some Qnap systems have a bug that the /opt folder is not added to the path. Here is how to modify the optware startup accordingly:
* Open Optware.sh (nano /etc/init.d/Optware.sh)
* Search for the line (you can use ctrl-W for that)
# adding Ipkg apps into system path ...
and replace it with the code below until before the lines
;;
stop)
- Code: Select all
# adding Ipkg apps into system path ...
/bin/cat /etc/profile | /bin/grep "PATH" | /bin/grep "/opt/bin" 1>>/dev/null 2>>/dev/null
# Bug fix for following: put IPKG first, per http://forum.qnap.com/viewtopic.php?f=124&t=15663
# was [ $? -ne 0 ] && /bin/echo "export PATH=$PATH":/opt/bin:/opt/sbin >> /etc/profile
[ $? -ne 0 ] && /bin/echo "export PATH=/opt/bin:/opt/sbin:\$PATH" >> /etc/profile
# Added by Lukas Oesterreicher to enable finding any /opt libraries
/bin/echo "/opt/lib" >> /etc/ld.so.conf
/bin/echo "/opt/local/lib" >> /etc/ld.so.conf
# uncomment line below only if you have libc-dev installed and need the libraries
#/bin/echo "/opt/i686-unknown-linux-gnu/lib" >> /etc/ld.so.conf
/sbin/ldconfig
# Patch per http://wiki.qnap.com/wiki/Install_Optware_IPKG
/bin/echo "Run Optware/ipkg /opt/etc/init.d/*"
source /etc/profile
# Start all init scripts in /opt/etc/init.d
# executing them in numerical order.
#
for i in /opt/etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
#[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
# End patch
Plase note that this code is not perfect. Currently for instance it appends to /etc/ld.so.conf creating duplicate lines with each reboot or restart of the service. You are free to suggest corrected code!
* Save the changes (ctrl-X and then Y)
* The changes only become effective either after restarting optware (/etc/init.d/Optware.sh restart) or restarting the whole NAS and loggin in with ssh again.
Now subsonic should be set up and data should be maintained.
This is the end of the basic guide. The next post will contain advanced setup so transcoding is supported and improved video streaming over the standard recommended ffmpe, using a modified build of mplayer2 that also supports encoding.
A basic instruction (that misses some details but on which I based my efforts on) can be found here: http://forum.subsonic.org/forum/viewtopic.php?t=1851
Hope this helped you get Subsonic running.