CentOS 6.2 and miniDLNA

This is a blog about why miniDLNA is awesome.

So enjoying all Linux has to offer one thing that interested me is along the lines of the old adage: Laziness is the father of Invention.  I enjoy my DVD collection, but ever since Netflix I have been ruined with getting up and putting DVDs in the drive.  Many times I’ve opted to watch a movie I own on Netflix instead of using the DVD because it was easier.  So began my search for a reliable DLNA server.

Why miniDLNA?  Well first let’s start with the fact that there are a lot of DLNA type servers out there.  That do things quite differently.  I wanted one that was reliable.  My secondary concern was that I wanted one that didn’t try to do everything.  I didn’t need web interfaces or transcoding.  miniDLNA does just the sharing.  What your device does with the data is up to it.  It gives a good guarantee that it will work with the majority of devices.

A quick rundown on DLNA.  It’s a working group built with a primary purpose of connecting various media devices to share your legal content while maintaining some semblance of protecting copyright holders.

Finally a note.  To get miniDLNA working it requires considerable amount of packages to be installed to CentOS.  I live by the “lean is mean” mentality and would not recommend installing this on a production machine that has other purposes.  A fresh box would be ideal, but my own home linux machine is pretty cluttered.


  • You have a location called /data/stuff that will be used to store the media files
  • That your server is called www at the domain example.com or www.example.com.
  • That, once again, you’ll have a user named bob that has sudoers privileges and that will be used to do all the work.


miniDLNA requires the RPMForge repository for Cent.  There are quite a few required dependencies.  First, if you don’t already have it.  Install the RPM and it’s DAG key.  The DAG key sometimes likes to turn — into – when you copy paste it. If it fails makes sure you have two dashes.

[bob@www ~]$ sudo rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

[bob@www ~]$ sudo rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Next install the required dependencies.  If this is a live machine some of these you may already have.  If this step fails you may need to install the EPEL repository for Cent.  Refer to my previous blog CentOS 6.2 and Netatalk to find out how.

[bob@www ~]$ sudo yum install {flac,libogg,libid3tag,libexif,sqlite,ffmpeg,libvorbis,libjpeg}-devel gcc

Next we need to get the source and make it.  As of now the current source is 1.0.24.  If it’s different change  lines 2, 3, 4 accordingly.

[bob@www ~]$  wget http://sourceforge.net/projects/minidlna/files/latest/download

[bob@www ~]$ tar -xf minidlna_1.0.24_src.tar.gz

[bob@www ~]$ cd minidlna-1.0.24

[bob@www minidlna-1.0.24]$ make


Now that we have minidlna made and ready to go we have to install it.

[bob@www minidlna-1.0.24]$ sudo cp minidlna /usr/sbin/

[bob@www minidlna-1.0.24]$ sudo cp minidlna.conf /etc/

Next we want to create the init.d script.  I’m not an expert at writing these scripts so I borrowed from a link below and modified.  If you notice something wrong or can be improved please feel free to comment.

[bob@www minidlna-1.0.24]$ sudo vi /etc/init.d/minidlna

Enter in all the preceding text into the file and save.  If you don’t want to write all this I highly recommend using this link to copy and paste:  http://pastebin.com/nUFX7mVh

#! /bin/sh
# chkconfig: 345 99 10

# description: Fedora Startup/shutdown script for MiniDLNA daemon

# If you have chkconfig, simply:

# chkconfig –add minildna

# Proper init scripts on Linux systems normally require setting lock

# and pid files under /var/run as well as reacting to network

# settings, so you should treat this with care.

# Original author:  Perry Clark <omfgppc (at) gmail.com>

# Modified by: David Gleich <rathelm.wordpress.com>


# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Installation details



# Where to keep a log file


# Where the PID & Lockfile lives





# The path that is to be used for the script


set -e

# Only start if we can find the minidlna.conf.

test -x $MINIDLNA || exit 0

# Parse command line parameters.

case $1 in


        echo -n “Starting MiniDLNA: “

        $MINIDLNA -f $ARGS -P $PID_FILE  >> $MINIDLNA_LOG 2>&1


        [ $RETVAL -eq 0 ] && touch $LOCKFILE





        echo -n “Stopping MiniDLNA: “


           for pidf in `/bin/ls $PID_FILE 2>/dev/null`; do

            if [ -s $pidf ]; then

                kill `cat $pidf` >/dev/null 2>&1


                [ $RETVAL -eq 0 ] && echo_success

                [ $RETVAL -ne 0 ] && echo_failure


                        rm -rf $PIF_FILE

           [ $RETVAL -eq 0 ] && rm -f $LOCKFILE





        echo “Restarting MiniDLNA: “

    $0 stop

        sleep 2

        $0 start



        # Print help

        echo “Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}”

        exit 1



exit $RETVAL

After that file is created we need to set the proper permissions for the file.

[bob@www init.d]$ sudo chmod 755 /etc/init.d/minidlna

Setup and Starting

Last we need to open up the proper ports in iptables, edit the config file and turn on the server.  Open up iptables and add.  Again be careful here with copying.  the — in front of state and dport can be lost.  Just double check before you save iptables.

[bob@www minidlna-1.0.24]$ sudo vi /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp -p tcp –dport 1900 -j ACCEPT

-A INPUT -m state –state NEW -m udp -p udp –dport 1900 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 8200 -j ACCEPT

One thing to note here is that it is critical to have a port open for the presentation url.  Some DLNA players require it in order to play.  One of note is the Xbox 360.  Without it your server will not show up.

Next is to edit the minidlna config file.

[bob@www minidlna-1.0.24]$ sudo vi /etc/minidlna.conf


friendly_name=Whatever you want


There are a few more settings you can tweak, but these 3 are the main ones to get up and running as quickly as possible.  The file is well commented and you should be able to figure out any other changes you may need to make.

The last thing to do is restart iptables and to turn on minidlna.

[bob@www minidlna-1.0.24]$ sudo service iptables restart

[bob@www minidlna-1.0.24]$ sudo service minidlna start

[bob@www minidlna-1.0.24]$ sudo chkconfig minidlna on

You should have a working findable, through uPnP, media server.  If you have a lot of files is does take time for it to build it’s a database but you can always check it by pointing a web browser at http://www.example.com:8200

Here are some of the reference links that I used to build this article.






Cent OS6.2 and Netatalk 2.2.0

This is a guide on how to install Netatalk 2.2.0 onto CentOS 6.2.  There’s plenty of other guides out there, but unfortunately they all have existing problems.  Either they are not current for the existing software or they are for different platforms of Linux.  This guide is designed for someone of novice skill level to take a fresh install of Cent and get AFP home directories working.  Adding other file shares or time machine disks are easy and other existing guides cover those topics just fine.  This entire guide assumes that no GUI has been installed and all commands will be given through the CLI.  All commands will be italicized.


To begin I am going to assume that you have Cent installed and updated.  Also I will assume that you have a user besides root, who will be referred to as bob from now on, that is in the sudoers file.

The first step is to create another user called mockbuild.  This is for building the needed RPM.  The Cent team highly recommends that you install all software through RPMs instead of source installs for optimal compatibility.

[bob@machine ~]$ sudo useradd -u 10000 -M -s /sbin/nologin mockbuild

Next we will install the required dependencies to build the RPM.

[bob@machine ~]$ sudo yum install {openssl,pam,db4,libgcrypt,avahi,libacl,openldap,cracklib,quota,tcp_wrappers}-devel libtool avahi rpm-build

Next we’ll create the RPM build directories.

[bob@machine ~]$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

[bob@machine ~]$ echo ‘%_topdir %(echo $HOME)/rpmbuild’ > ~/.rpmmacros

EDIT:  Sometimes the second line fails if you do a direct copy and paste.  If it gives you an error message just delete both ‘ and readd them in the command line.

Next we need to download the netatalk source file.  The newest version, as of this writing, is 2.2.2.  However the only source file they have is for el6 which is Red Hat Enterprise Linux version 6.  This version uses systemctl instead of init.d for loading and unloading services.  CentOS 6 still uses the older version instead of the newer one.  So we need to find sources for Fedora 15 and less.

[bob@machine ~]$ wget http://kojipkgs.fedoraproject.org/packages/netatalk/2.2.0/2.fc15/src/netatalk-2.2.0-2.fc15.src.rpm

Next is to begin building the RPM.

[bob@machine ~]$ rpm -ivh netatalk-2.2.0-2.fc15.src.rpm

[bob@machine ~]$ cd ~/rpmbuild/SPECS

[bob@machine SPECS]$ rpmbuild -ba ./netatalk.spec

[bob@machine SPECS]$ cd ../RPMS/x86_64

If all went well when you ls in this directory you should see two RPMS.  A dev one and a normal one.


This part is pretty easy as it’s only one line.

[bob@machine x86_64]$ sudo rpm -ivh netatalk-2.2.0-2.el6.x86_64.rpm

This should have created a directory /etc/netatalk and a service in /etc/init.d/ called netatalk.  The default settings should be sufficient to test whether netatalk is working correctly or not, but part of making AFP, AFP is it shows up in the finder side bar.  So there’s a couple of files that still need to be tweaked.  First we need to add the AFP port to iptables.

[bob@machine x86_64]$ sudo vi /etc/sysconfig/iptables

After the line that accepts the SSH port add:

-A INPUT -m state –state NEW -m tcp -p tcp –dport 548 -j ACCEPT

Reload iptables so the changes take effect.

[bob@machine x86_64]$ sudo service iptables restart

Next we need to edit the avahi services directory to allow AFP to show up with bonjour.

[bob@machine x86_64]$ sudo vi /etc/avahi/services/afpd.service

The file will be a new file.  Just add this text in the file.  One thing to note is that I use Xserve as the model.  I prefer to use Apple’s server icon for servers, but you can choose any of the these options: Macmini, iMac, MacPro, Xserve, MacBook, MacBookPro or MacBookAir

<?xml version=”1.0″ standalone=’no’?><!–*-nxml-*–>

<!DOCTYPE service-group SYSTEM “avahi-service.dtd”>


    <name replace-wildcards=”yes”>%h</name>











That completes the basic installation for the service.  Next is to turn everything on and make sure they stay on after a reboot.

[bob@machine x86_64]$ sudo chkconfig netatalk on

[bob@machine x86_64]$ sudo chkconfig avahi-daemon on

[bob@machine x86_64]$ sudo service avahi-daemon start

[bob@machine x86_64]$ sudo service netatalk start

You should now have a working installation of netatalk 2.2.0 for CentOS 6.2.  This version of netatalk will work with Lion versions of OS X.  Special thanks to these websites for bringing the majority of this content: