We realise this here with the rather lightweight DLNA server MiniDLNA. This tool is available from the repositories. An updated version and good support can be obtained from the project's page with sourceforge.
When installing the DEB package from the repositories the application can be run by
sudo service minidlna start
using its default configuration file
/etc/minidlna.conf. This file needs to be edited for defining media directories, database cache directory, and network properties. Scanning your media for changes in content will be done in defined intervals but you can also force a rescan at any time with:
sudo service minidlna stop
sudo minidlna -R
Scanning of the media for building the database may take quite a long time with large libraries or huge files. Once done it runs quite stable in the background. You can also define an upstart script to run on boot.
Settings for the init script can be made in
/etc/defaults/minidlna. This is especially helpful when we want to run MiniDLNA as a certain user (e.g. when the database is stored in a HOME directory).
See also: https://help.ubuntu.com/community/MiniDLNA on how to run minidlna from userspace. You then may also be interested in the MiniDLNA Indicator.