Installing Serviio 1.10, Kubuntu/Ubuntu 18.04, FFMPEG 3.4.x
General Notes:
This installation is based on Kubuntu 18.04 LTS 64 bit http://kubuntu.org/ . Kubuntu is an official release of the Ubuntu project.
There are three broad groups of actions to get Serviio up and running on Linux. First we check for Java, then we check for a supported version of ffmpeg, and finally we install Serviio itself. If you actually need to build ffmpeg then look for one of my older posts (SparkyHenderson) for instructions.
I avoid using third party repositories whenever possible. All the software installed in these instructions either comes from the official Ubuntu/Kubuntu repositories or from the developers' web sites. With these instructions it's easy enough to build ffmpeg just the way you need it without opening yourself up to an anonymous source's choices that aren't appropriate for you.
I'm starting with a VMware virtual machine setup with 2048 MB of RAM, 2 virtual CPU cores, and a single NIC. You may be able to use less RAM, but I think a minimum of 2 CPU cores is important for smooth performance. If you choose to use my optional RAM drive trick (towards the end) to speed up ffmpeg transcoding, you will be very glad you had 2 or more CPUs. I have tested the virtual machine under VMware's vSphere 6.5 and Fusion 10. (I am a VMware nerd.) I do my installations logged in as root. You may want to do all this as a sudoer by prepending "sudo" to all the commands below. Be my guest, but I would lose my mind; my mind is already wandering just thinking about it.
Quick refresher - If you need to unlock the root account in Ubuntu, first set the root password, then unlock the account like this (please lock it back up when you're done):
Keywords:
Serviio, Linux, server, media server, headless, DLNA UPnP, Kubuntu, Ubuntu, Java, Oracle, JRE, ffmpeg, build, NAS, lossless, flac, wav, mpc, lossy, mp3, ogg, vorbis, Ubuntu 18.04, Kubuntu 18.04, systemd
Just a thought! - You virtual machine builders may want to take a snapshot here. (We'll do this a few times throughout this set of instructions.)
I recommend you install and use aptitude. The options are just a little different from apt and apt-get, but you can accomplish all the same tasks. (I like aptitude for its safe-upgrade option.)
******************************************************************************************
Don't do this - Install Oracle Java
******************************************************************************************
Notes:
The Open JDK is perfectly robust now. In my case it's "10.0.2" 2018-07-17. As a big bonus we now get regular updates without doing any manual magic. Just relax and go with what's installed with Ubuntu 18.
Do not install the Oracle Java 11 JDK. It won't work because parts of Java EE have been completely dropped from the Java 11 JDK and there are no more JRE or Server JRE downloads available. Oracle isn't winning any friends here and Serviio will need to have some code revision to get past this. The fix that works for Java 9 and Java 10 simply fail now. Stick with the Open JDK.
******************************************************************************************
ffmpeg
******************************************************************************************
Notes:
Finally. FINALLY! Finally Ubuntu is up to speed with a very current ffmpeg instead of some ancient after though version. The Ubuntu 18.04 LTS repositories now contain version 3.4.4, which is the version the Serviio 1.10 is happy with. As of this writing the latest version 3 branch from ffmpeg.org is 3.4.5. For the first time I'm not building my own version of ffmpeg and I'm sticking with the Ubuntu repository version.
If you are on Ubuntu 18.04 LTS or above then just do this:
If you are on an older version of Ubuntu then find my older instructions on building your own ffmpeg.
******************************************************************************************
Serviio server installation
******************************************************************************************
Notes:
This is the easiest part of the whole process. If you needed to install a different version of Java or build your own FFMPEG then you may be wishing you had gone with the Windows or Mac version, but you're here now so let's do this!
I have chosen to install the Serviio under the /opt directory structure. Why? Because Serviio stores its data under its installation directory and I really dislike when programs store data in any of the ./bin or ./sbin directories (/, /usr, or /local). I see it as FHS directory polution. Just my opinion. Some days I'm just a little cranky. But seriously, install it wherever you want. Just substitute your path as appropriate.
I create a symlink in /opt called /opt/serviio. This lets me completely change the actual Serviio software to a different version or do a clean installation without having to change my desktop shortcuts or other scripts. Great for doing updates while preserving your database and settings! Just change the symlink in one place to the new/desired Serviio directory and everything else just works.
Highly recommended - Perform the optional steps below to create a dedicated user account with restricted rights to run Serviio programs. If you don't then you will need to set the appropriate file and directory permissions as needed on your own.
convenience copy:
Steps details:
I decided that RAW image support would be nice. If you want this too then install dcraw. Cut and paste:
Do I have to say to download Serviio? Nah, but I will anyway. Here's how I did it. Make sure you get the most recent version.:
Untar your serviio-whatever-the-tar-is-called to /opt. You will do something like this:
note: -C makes tar change directory first then unpack
Make a symlink in /opt from your specific version directory to a generic directory link called /opt/serviio/ like this:
The user and group will be essentially unset (set to some numerical value that may or not match existing UID). Do consider setting user and group information to an appropriately restricted user. See the optional steps just below. If you don't want to create a restricted user account then just set the user and group to whatever you like. You will find the server and console start scripts in /opt/serviio/bin .
Enjoy!
Just a thought! - You virtual machine builders may want to take a snapshot here.
******************************************************************************************
Create a restricted user account to run Serviio and set permissions
******************************************************************************************
Notes:
We will create a limited user account, set the ownership and permissions, and finally create a startup script and configure it to run at boot.
The way I'm doing it here, only the user serviio and root will be able to get to the log and config files. If you have a designated user that needs to get to these files just add them to the serviio group.
Important -> Did you make the symlink I suggested? All the commands below rely on that symlink you created.
chown does not follow symlinks by default. Add the -L flag.
chmod always follows symlinks.
Do not test run Serviio from the root account. Don't do it! Even though we're creating a user with no default shell, you can still use that restricted account to launch Serviio from the command line. I'll show you how. You do not need to test by using the root account. (OK, it is your system, so go ahead if you must. It's not my place to tell you what to do, but I wouldn't do it. I admit that I actually did test as root the very first time I started this write up, but then I rolled back to my previous snapshot.)
Convenience copies of the commands for adding the user and setting the permisions are right here for your convenience. See the individual commands below for explainations.
- The adduser command only needs to be run the very first time you install, not for subsequent upgrades.
- Add a user named serviio. (Whatever you want to call it is fine.)
- Setup the new user as a system user that, by default, will have no login shell.
- Create a group with the same name and use as primary.
- The password is disabled for tighter security.
- This compound command updates ownership and permissions, and should be run every time a new version is installed.
Just a thought! - You virtual machine builders may want to take a snapshot here before you run Serviio for the first time.
******************************************************************************************
Run Serviio from the command line using our restricted user account.
******************************************************************************************
Notes:
Do not run Serviio as root. Don't do it! Even though our limited serviio user has no default shell and the password is disabled, there is an easy way to run the program. You do need to be logged in as root to run this command, but the command will run using only the serviio user permissions.
Steps:
Run the Serviio server like this:
- use the super user command
- tell it to use the bash shell
- tell it to run the command /opt/serviio/bin/serviio.sh
- tell it to use the user serviio
You should see "Created user preferences directory" the first time you run Serviio using the command above. This message will not be shown on subsequent runs.
At this point you could start the console with the script in /opt/serviio/bin but it's easier just to use the URL directly.
To test this from a different machine just change "localhost" to the appropriate IP address or URL. Don't forget to add "console".
Once you're satisfied Serviio is happy then just Ctrl+C to break out of the server. It will close cleanly.
(A little off topic.)
An easy way to test audio transcoding fast is to set your device's profile to DirecTV and restart Serviio. This profile transcodes nearly everything, so pick a non-mp3 audio file and see if it gets delivered as an mp3 to your renderer.
******************************************************************************************
Optional performance tweak - setup a RAM drive for transcode operations
(this will be 10x or more faster than any SSD)
******************************************************************************************
Notes:
I do not know what the behavior with videos that are larger than the RAM disk is. I didn't test that aspect. Do some research and please tell me how it worked out for you.
This assumes you will use the system /tmp for transcoding. If you will transcode to a different directory you will have to modify the line you add to fstab.
Beware that if your total RAM is too low then all kinds of ugly swap file action will take place and your system will slow to a crawl. I tested with 3GB of RAM, I think 2GB would work too.
The noexec option is not appropriate if you will use this machine for compiling and building other apps. Build tests will frequently use /tmp to save executable files and then try to run them. I use the noexec parameter because my "NAS Gizmo" is not my development machine. I also use noexec on the entire /home directory tree.
Steps:
Edit your /etc/fstab and add the following line. Cut and paste:
- There is no source device.
- Assumes you are mounting at /tmp (make this match whatever you set as the transcode directory).
- The tmpfs file system type is dynamic and only takes as much RAM as it needs without preallocating.
- The options nodev and noexec will help with security a little bit.
- I used size=25%, which uses up to 25 percent of the total RAM.
- 0 0 just standard dump etc. options.
When you look at your mounted devices you should see a line that is similar to this:
none on /tmp type tmpfs (rw,nodev,noexec,relatime,size=507480k)
******************************************************************************************
systemd launch at boot up script - for Ubuntu 15.04 and above
******************************************************************************************
Lifted directly from the wiki at: http://wiki.serviio.org/doku.php?id=how ... buntu15-04
They really made this easy.
create a file /lib/systemd/system/serviio.service
put the following inside of it:
Do the following commands:
The service runs using the name java and not Serviio. I don't know how to make the name that shows up with a ps command any different. Let me know if you figure it out.
Just a thought! - Everything running the way you like? Now might be a good time to export your VM to a template file (OVA, OVF, etc.). You can delete those pesky snapshots too.