Media On Demand HOWTO, NAS4Free and Serviio

jonathan Home Netwoking 2 Comments

We have a new Jail but now we need to install and configure Serviio which is what I use for my DLNA service. Go to the NAS4Free web GUI, click the ‘Extensions’ menu and ‘TheBrig’ sub-menu. Now from here let’s start the Jail by clicking the icon below, its red in this screenshot to turn it off but it’ll be green when we first click it as the Jail instance is off after it has been created.


Now SSH to the NAS4Free instance and check your jail status by running the command


This will list your jails of which we need to select the one we just created. Run the command below to access the jail’s root (where the number is the jail number)

jexec 1 csh

The first change I normally make is to create some new folders where we can point the folders we want to share from the NAS4free NAS file store to within the Jail. For example, lets make a TV and Film folder.

mkdir /mnt/TV
mkdir /mnt/Films

Lets add a new user (give it whatever name you want) by typing


Follow the prompts selecting defaults with the exception of the secondary groups, here we need to add the user to the additional group called ‘wheel’ without the apostrophes. This will give the new user SU access.


Ok, finally lets make life a little easier and enable SSH access so that we can make the rest of the changes without needing to log in to the NAS4Free system. Execute this command

echo 'sshd_enable="YES"' >> /etc/rc.conf

exit out of the Jail session and then go back to TheBrig dashboard and stop the Jail by hitting the red button shown in the first screenshot.

If you’ve been following these posts you’ll probably remember the Fstab section in the Jail edit from the ‘Setting the Jail Rules, NAS4Free’ post. Lets get back to this section, once there we can now add in the folders we want to share from the NAS4Free store to the Jail we created.

The command we need to type is the NAS4Free store folder followed by the Jail folder we want to point to and then some system commands including whether we have read-write or read-only access to the NAS4Free NAS store folder. It’ll look like this:

/path/to/your/tvfolder/TV /mnt/TV nullfs ro 0 0
/path/to/your/filmsfolder/Films /mnt/Films nullfs ro 0 0

Save the settings and press the green button mentioned at the start of this post to restart the jail. Now we need to enable ports access to our Jail so that we can build the Serviio application, we can do this from the NAS4Free GUI within TheBrig dashboard. Click the ‘Updates’ tab and then the ‘Central Ports’ under this. We then select the ‘Fetch and Update’ button, once this is finish we click the ‘Port Tree Enabling’ button beside the Jail name and click save at the bottom of the screen.


Now we need to SSH to the IP address of the Jail and log in with the new user we created so we that install and configure Serviio.

Once logged in, type ‘su’ for root access.

Lets configure the domain name of the machine which serviio needs, edit the hosts file

vi /etc/hosts

and make sure there is an entry with the IP of your Jail and the Fully Qualified Domain Name (FQDN) of your machine for example ‘serviio.local’ without the apostrophes. Now save the changes.

All of this is really mechanical but we can build the Serviio application now. SSH and login back to your Jail. Type ‘su’ for root access and change directory by typing

cd /usr/ports/net/serviio/

now its time to build, type

make clean install

You can accept the default for most options except FFMPEG, while it is building we need to select the following options (note some of these will already be selected)


This will take time, for me it took a few hours so make sure you’ve something to watch or a good book to read.

The port build script for this release installs the wrong version of Java so we need to uninstall it and install version 8. Let’s uninstall the wrong one and install version 8.

cd /usr/ports/java/openjdk7
make deinstall
Install the right verion
cd /usr/ports/java/openjdk8
make -DBATCH clean install

Again this will take some time but at least we won’t get any prompts so we can leave the install to work its magic.

Serviio uses the dlna user for its runtime and we need to make some changes to accommodate this. We create a new home directory and change the owner to the dlna user

mkdir /home/dlna
chown -R dlna:dlna /home/dlna
Now we change the home path for the dlna user

chsh dlna

we also need to change permissions for other serviio related files and folders

chown -R dlna:dlna /usr/local/etc/serviio
chown -R dlna:dlna /usr/local/share/java/classes/serviio/

We need to ensure Serviio will start at boot by typing

echo 'serviio_enable="YES"' >> /etc/rc.conf

We also need to setup Serviio with a few parameters, note change ‘IP’ to the IP of your Jail

echo serviio_args=\'-Dserviio.advertisementDuration=\"15\" -Dserviio.remoteHost=\"IP\"\' >> /etc/rc.conf

That’s the majority of what we need but there are a few other things we need to do.

I normally enable the web GUI which we developed by a third-party. This allows us to control Serviio without the need for a console client. To configure this we first install Apache by typing

cd /usr/ports/www/apache24
make -DBATCH clean install

Once done make sure Apache will survive a reboot

echo 'apache24_enable="YES"' >> /etc/rc.conf

Now we need to follow the same steps for PHP

cd /usr/ports/www/mod_php55

make -DBATCH clean install

Copy the base PHP config file to the active file

cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini

We need to enable PHP within Apache by changing it’s config, edit the config file by typing

vi /usr/local/etc/apache24/httpd.conf

Make sure ‘index.php’ is part of your ‘DirectoryIndex’.

and at the bottom of the config file add

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Save and create a test PHP file

echo "<?php phpinfo(); ?>" >> /usr/local/www/apache24/data/test.php

There are also a bunch of PHP dependencies that we need to install

pkg install php55-curl php55-xml php55-mbstring php55-simplexml php55-json php55-dom dcraw

Now we’re ready to start Apache

apachectl start

Open a browser and browse to your test file http://IP/test.php were the ‘IP’ is the IP of your Jail.

We now need to install the web GUI, first install wget

pkg install wget

and go to the tmp directory

cd /tmp

download the web GUI files from here:

unzip the zip file by typing


where X.X is the version of the release we’ve downloaded.Now change the directory the the newly extracted folder

cd Web-UI-for-Serviio-Serviio-X.X

and copy the contents to the HTTP web root

cp -r * /usr/local/www/apache24/data/

Ok if you’ve kept up at this point we can now start Serviio by typing

service serviio start

And stop it again

service serviio stop

It might seem a little odd that we’ve just done that but we need to change file permissions

chown -R dlna:dlna /var/db/serviio
chown -R dlna:dlna /var/log/serviio

Now start Serviio again

service serviio start

That’s it, we’re done! We can now add in your directory shares… YAY! Just one small note, I noticed with the release of Serviio I’m using 1.5.2, the web GUI add/remove folder isn’t working very well. I’d recommend using the Serviio console or app for the time being. Ping me if you have any issues.

Comments 2

  1. Hi, I’m at a loss regarding the fstab entry. Let’s just say I want “/mnt/DefaultPool/Download/” on my NAS4free to be available in my jail, the path to the jail being “/mnt/DefaultPool/jails/SABnzbd/”, what would be the exact entry? This has been driving me wild …
    Thanks a lot!

  2. Post

    Hey Bart,

    Thanks for getting in touch. Sorry about the fstab entry example, it wasn’t very clear. What you need is the following:

    First logon to your jail console and create a new directory: mkdir /MyDirectory

    Now your fstab entry will look like this:
    /mnt/DefaultPool/Download/ /mnt/DefaultPool/jails/SABnzbd/MyDirectory nullfs ro 0 0 where ‘ro’ is readonly. If you want the directory to be read/write change the ro to rw.

    If you’re still having issues check your folder file permissions on the Jail directory you created and make sure that the process which is trying to access the directory with has permissions to read/write.

    I hope this helps, if not, feel free to reply.

    Cheers and Good Luck!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.