標籤:fedora minidlna 服務配置
搭建 dlna 伺服器主要作為 samba 的補充,簡單方便。windows 7 已經內建流媒體共用,設定也很簡單,可以自行上網搜尋。
在linux搭建的目地主要是作為家庭媒體共用伺服器,手機和智能電視訪問比較方便。
我之所以沒有用 CentOS 而用了 fedora 系統,主要是因為在筆記本上僅添加 rpmfusion 這個repo就夠了,安裝驅動什麼的比較方便,全部使用 dnf 安裝不需要自己編譯,其他發行版也是大同小異。
如果沒有安裝的得先裝上 rpmfusion-free-release rpmfusion-nofree-release 這兩個包,再重新整理 dnf 緩衝就行。
在國內的話按下面操作就行,要修改成對應的作業系統版本,我這裡用的是 fedora 22。
[[email protected] ~]# wget http://mirrors.aliyun.com/rpmfusion/free/fedora/rpmfusion-free-release-22.noarch.rpm[[email protected] ~]# wget http://mirrors.aliyun.com/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-22.noarch.rpm[[email protected] ~]# rpm -ivh rpmfusion-free-release-22.noarch.rpm rpmfusion-nonfree-release-22.noarch.rpm[[email protected] ~]# dnf update
所有的 repo 檔案放在 /etc/yum.repos.d/ 下面,如果嫌速度不夠快可以自行配置使用國內的鏡像網站,怎麼修改可以上網查查,更新後先重啟。
首先先搜尋一下有關 dlna 的軟體。
[[email protected] ~]# dnf search dlna上次中繼資料到期檢查在 2:58:13 前執行於 Mon Dec 21 13:13:02 2015。=========================N/S 匹配:dlna ==========================================gupnp-dlna-docs.noarch : Development package for gupnp-dlnagupnp-dlna-devel.i686 : Development package for gupnp-dlnagupnp-dlna-devel.x86_64 : Development package for gupnp-dlnaminidlna.x86_64 : Lightweight DLNA/UPnP-AV server targeted at embedded systemsgupnp-dlna.i686 : A collection of helpers for building UPnP AV applicationsgupnp-dlna.x86_64 : A collection of helpers for building UPnP AV applicationsrygel.i686 : A collection of UPnP/DLNA servicesrygel.x86_64 : A collection of UPnP/DLNA services
安裝 minidlna 軟體
[[email protected] ~]# dnf install minidlna.x86_64
查看軟體包檔案清單
[[email protected]ora ~]# rpm -ql minidlna.x86_64/etc/minidlna.conf/run/minidlna/usr/lib/systemd/system/minidlna.service/usr/lib/tmpfiles.d/minidlna.conf/usr/sbin/minidlnad…………省略…………/usr/share/man/man5/minidlna.conf.5.gz/usr/share/man/man8/minidlnad.8.gz/var/cache/minidlna/var/log/minidlna
軟體檔案很簡單的。
可以自己看看 minidlnad 的 man 手冊
[[email protected] ~]# man minidlnad
運行 minidlnad -h 也差不多
[[email protected] ~]# minidlnad -h
也可以再看看 minidlna.conf 手冊。
[[email protected] ~]# man minidlna.conf
接著看看 minidlnad 的 service 檔案
[[email protected] ~]# cat /usr/lib/systemd/system/minidlna.service[Unit]Description=MiniDLNA is a DLNA/UPnP-AV server softwareAfter=syslog.target local-fs.target network.target[Service]User=minidlnaGroup=minidlnaType=simpleExecStart=/usr/sbin/minidlnad -S[Install]WantedBy=multi-user.target
看來最主要的就是執行 /usr/sbin/minidlnad -S 這個命令。之前運行 minidlnad -h 有說明,“-S”代表以systemd的方式運行服務。
看來是一個比較簡單的服務。
設定檔路徑一般在 /etc/minidlna.conf,使用常用的編輯器修改就行。
我們可以基本瞭解所有的設定都可以在 minidlna.conf 設定檔中修改,重點就主要看看 minidlna.conf 的配置選項。
接下來修改設定檔 minidlna.conf。
[[email protected] ~]# vi /etc/minidlna.conf# 自訂網頁訪問的連接埠,用於狀態資訊等。預設連接埠號碼為8200,那麼訪問 http://127.0.0.1:8200,就可以看到相關的狀態資訊(其實是一個很簡單的網頁)。port=8200# 指定服務網路介面,預設所有介面。多個介面用“逗號”分開,例如 network_interface=eth0,enp3s0。#network_interface=eth0# 指定使用哪個系統使用者來運行服務。使用者名稱或 UID 都可以。systemd 方式不需要修改這個,在 /usr/lib/systemd/system/minidlna.service 已經指定了。#user=jmaggard# 設定共用目錄。多個目錄需要多次指定。# 可以通過下面的方式限定目錄存放的媒體類型# + "A" 代表音樂 (例如:media_dir=A,/home/jmaggard/Music)# + "V" 代表視頻 (例如:media_dir=V,/home/jmaggard/Videos)# + "P" 代表照片 (例如:media_dir=P,/home/jmaggard/Pictures)# + "PV" 代表照片和視頻 (例如:media_dir=PV,/home/jmaggard/digital_camera)# media_dir=/opt 代表 /opt 目錄下有多種類型的檔案。# 是否將上面多個 media_dir= 合并到一個根目錄下。預設為 merge_media_dirs=no 不合并,如果 media_dir= 比較多比較亂可以選擇合并。#merge_media_dirs=no# 自訂用戶端顯示的主機名稱,可以理解為你自己的近端分享的名稱,不設定的話會使用當前的主機名稱。#friendly_name=My DLNA Server# 指定存放專輯封面等快取資料的路徑,一般不需要修改。確保對這個目錄有寫入權限就行。#db_dir=/var/cache/minidlna# 指定日至存放目錄,一般不需要修改。確保對這個目錄有寫入權限就行。#log_dir=/var/log/minidlna# 指定日誌記錄等級,每個 section 可以使用不同的等級:off, fatal, error, warn, info, debug。看著不太重要,具體沒仔細研究。#log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn# 使用斜杠 "/" 分隔的可能存在的專輯封面的檔案名稱。如果發現有其他的檔案就再再加上去。預設已提供了下面的設定。album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg# 是否使用 inotify 通知來自動探索新的檔案。預設 inotify=yes。# 一般 linux 發行版設定 inotify 為 8196,啟動服務後會報錯,實際並不影響使用,本文最後附有解決方案。inotify=yes# 好象是數字錄影機支援,沒用到過。預設 enable_tivo=no。# set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMOenable_tivo=no# 是否嚴格遵守 DLNA 標準,預設 strict_dlna=no。# 這會允許伺服器自動縮放非常大的圖片,會影響圖片儲存的品質(至少)在 Sony DLNA 產品中會有這類情況。# 對硬碟上的圖片檔案是否影響有待測試。還是建議為 strict_dlna=no。strict_dlna=no# default presentation url is http address on port 80#presentation_url=http://www.mylan/index.php# 通知時間間隔,預設895秒。#notify_interval=900# serial and model number the daemon will report to clients# in its XML descriptionserial=12345678model_number=1# 指定 MiniSSDPd socket 的路徑,好像沒用到過。#minissdpdsocket=/var/run/minissdpd.sock# use different container as root of the tree# possible values:# + "." - use standard container (this is the default)# + "B" - "Browse Directory"# + "M" - "Music"# + "V" - "Video"# + "P" - "Pictures"# + Or, you can specify the ObjectID of your desired root container (eg. 1$F for Music/Playlists)# if you specify "B" and client device is audio-only then "Music/Folders" will be used as root#root_container=.# 按照指定的排序條件進行,忽略用戶端的要求。#force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title# 允許最大同時串連數,注意:一個用戶端會開啟多個串連。#max_connections=50
設定開機自動啟動
[[email protected] ~]# systemctl enable minidlnad.service
啟動服務
[[email protected] ~]# systemctl start minidlnad.service
重啟服務
[[email protected] ~]# systemctl restart minidlnad.service
禁用開機自動啟動
[[email protected] ~]# systemctl disenable minidlnad.service
如果遇到這個警告:
WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [4] and I do not have permission to increase this limit. Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.
下面這些都能搞定。
[[email protected] ~]# echo 65538 > /proc/sys/fs/inotify/max_user_watches[[email protected] ~]# sysctl fs.inotify.max_user_watches=66538
永久生效需建立編輯 /etc/sysctl.d/90-inotify.conf
[[email protected] ~]# vi /etc/sysctl.d/90-inotify.conffs.inotify.max_user_watches = 66538
如果遇到這個警告:
upnphttp.c:1054: warn: HTTP Connection closed unexpectedly
請檢查電源管理軟體佈建包括但不限於 powertop、tuned等,一般是處於省電考慮把網卡給關掉了。
minidlna 適合伺服器安裝,依賴很少,只要改改設定檔就成。
其他類似的軟體:
rygel 適合圖形介面使用者,有專門的圖形介面配置,也很簡單。
mediatomb 帶有網頁介面配置,適合伺服器安裝。
找著找著發現有個 kodi 的軟體,搜尋一下之後頓時眼前一亮,等有時間再玩玩了。
本文出自 “老丁的linux” 部落格,請務必保留此出處http://laoding.blog.51cto.com/980622/1727488
fedora下安裝配置minidlna