linux server setup: file, ftp, web, tv, and gaming by misterhaan, jan 2008 (updated sep 2012)
this guide is the steps i went through when i upgraded my “server” hecubus to fedora 17. hecubus serves as a file server (samba and nfs), ftp server (pure-ftp), web server (apache, mysql, and php), personal video recorder (mythtv), and game server (tdsm and minecraft). setup for fedora 17 as well as these other packages are detailed. mythtv setup includes setting up hauppage hvr 2250 and pvr 150 cards with schedulesdirect guide information.
personal video recorder (mythtv)
recording tv to files on a hard drive is in many ways better than recording to vhs tape. i have mythtv record the shows i want to watch on my hauppage hvr 2250 and pvr 150 cards, then i play them on my htpc using a little program i wrote.
requirements for mythtv as a personal video recorder are some sort of linux gui (kde works well, which is why i install from the kde live cd image), a tv tuner card (this guide is for ivtv cards, which encompasses most analog hauppage cards, plus saa7164 cards, which is a newer digital tuner), and a good deal of hard drive space to hold the shows and / or movies you want to record. for reference, a half-hour hd surround show is 1.1 gigabytes in mpeg2 format. note that i always install and configure apache, php, and mysql before setting up mythtv. i suspect the mythtv installation will pull them in for you if you didn’t install them first, but if not then see the web server page of this guide.
to start, add the atrpms repository to yum:# cd /etc/yum.repos.d/
# yum -y install wget
# wget http://wilsonet.com/mythtv/atrpms.repo
# rpm --import http://atrpms.net/RPM-GPG-KEY.atrpms
edit atrpms.repo and change 2 places to fedora 7 version (which also works for fedora 8 through 17 — they changed the name from “fedora core” to just “fedora” in version 7, so fc became just f), then install mythtv from yum (note the suite has a lot of pieces so this will take a while):# yum -y install mythtv-suite
for the hvr 2250 card i need to install the saa7164 firmware. in a scratch directory (such as /tmp/), execute the following commands to download and install saa7164:$ mkdir hvr22xx
$ cd hvr22xx
$ wget http://www.steventoth.net/linux/hvr22xx/22xxdrv_27086.zip
$ wget http://www.steventoth.net/linux/hvr22xx/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
$ wget http://www.steventoth.net/linux/hvr22xx/firmwares/4019072/NXP7164-2010-03-10.1.fw
$ wget http://www.steventoth.net/linux/hvr22xx/extract.sh
$ sh extract.sh
# cp *fw /lib/firmware
you can now remove the hvr22xx directory that was created. the saa7164 driver that was already installed didn’t work correctly without the firmware, so reload it:# modprobe -r saa7164
# modprobe saa7164
mysql should already be set up with a password set for the root user and also running as a service. set up the default mysql databases using the provided sql file:$ mysql -u root -p < /usr/share/doc/mythtv-docs-0.25.2/database/mc.sql
log into the server in a kde session, and run mythtv setup from applications → multimedia in the menu. choose your country and language, then go through the options in order.
under general on the second screen locale settings, set channel frequency table to us-cable and local timezone to auto. the default settings are fine again for the rest of this section.
under capture cards, choose new capture card to set up your tuner card. first the hvr 2250 with two digital tuners needs to be added twice. set card type to dvb dtv capture card (v3.x). there should be two options under dvb device number — one for each tuner. leave it at the default. under recording options, set max recordings to 1. now add another card the same way. the second one will choose the other dvb device number for you.
now add the pvr 150. change card type to "mpeg-2 encoder card" and everything else defaults correctly.
under video sources, choose new video source. give it whatever name you like (for example, “xyz cable”). in the us or canada, schedulesdirect can hook you up with tv listings for $20/year after a free 7-day trial. unfortunately i don’t know of any free services. sign up for an account at schedulesdirect.org if you don’t already have one, and set up your channels on their site. i add a local broadcast listing for my digital cable channels and the regular cable listing for analog cable channels. back in mythtv, enter your user id and password, then click retrieve lineups. your lineups should come into data direct lineup. set up one video source for each lineup, even though i’m going to use the digital lineup twice.
under input connections, you connect your tuners to the listings. find your tuner in the list. enter a display name if you like (it’s nice to be able to tell which tuner is being used by this name). choose the appropriate video source you created earlier. for the first digital tuner choose scan for channels to get the channels tuned in. i do a full scan on cable frequency table with qam-256 modulation to pick mine up (it takes about 10 minutes). for analog tuners, click fetch channels from listings source to get the channels from schedulesdirect. on the second page, set priority for that tuner if desired. higher priority tuner will be preferred.
under channel editor, i edit each channel and change its name to the network it shows (i’d rather see nbc than wxxx). use icon download to get icons for all channels with download all icons, or you can enter them while editing the channels if you already have them somewhere. for digital channels you will also need to fill in the xmltv id according to what you see in schedulesdirect (it's a tooltip when you edit the listing) to have the listings match up. my digital scan found channels i didn’t want, so i deleted those by arrowing to each one and pressing D. i also mark the analog channels that are also available digitally as not visible so i don’t accidentally record the analg version of a show when i could have recorded the digital.
under storage directories, choose default, then add new directory. enter the directory you want mythtv to store recordings in and click ok. this directory should be shared through samba for easy playback on windows machines.
from a shell, get your tv listings into the database, then start and autostart the mythtv server:$ mythfilldatabase
# systemctl start mythbackend.service
# chkconfig mythbackend on
run mythtv setup from applications → multimedia in the menu for some additional configuration. go to setup. under video, general you can set defaults for recording schedules. i turn off auto expire default because i have enough space i can delete shows manually. under advanced i set time to record before start to 120 (2 minutes) and past end to 300 (5 minutes) to help catch the entire show if the channel is running a little early or late. i also set category of sports event to record 30 minutes past the end.
since i don't plan on logging into my server for x sessions, i use mythweb (installed to
/var/www/html/mythweb/ in case you need to point apache to it) to schedule recordings. access it from http://yourserver/mythweb/. to record something, first find the show either through browsing the listings from the link in the upper left, or using the search box in the upper right. click on the link for the show and choose whichever schedule option works best for you. click update recording settings and your show will be scheduled to record.
since i’m also running other sites, i change the DocumentRoot away from /var/www/html. to get mythweb to still be accessible, i set up an alias for /mythweb to /var/www/html/mythweb. this breaks mythweb, so edit /etc/httpd/conf.d/mythweb.conf and add “RewriteBase /mythweb” after “RewriteEngine on” to get it working again (you will need to restart the httpd service for this to take effect).
i also make mythweb available via the internet so I can schedule recordings even if i’m not home. to do this, set up a directory /var/www/html/mythweb-inet/ and point an apache virtualhost to it. it needs the same mythweb alias but also should use basic auth so only i can access my mythweb from the internet. here’s a sample virtualhost section you could modify and put in httpd.conf:<VirtualHost *:80xx>
Alias /mythweb /var/www/html/mythweb
AuthName "MythTV on hecubus"
make sure to set whichever port you intend to use in place of 80xx, and add a Listen 80xx to match. to handle the auth, create the directory and then the file with its first user. i also included the command for adding another user since it’s slightly different:# mkdir /etc/httpd/.htpasswd
# htpasswd -c /etc/httpd/.htpasswd/mythweb someuser
# htpasswd /etc/httpd/.htpasswd/mythweb anotheruser
both of the htpasswd commands will prompt for the user’s password. now we need that mythweb-inet directory and something to kick it into the mythweb alias directory. create /var/www/html/mythweb-inet as root, then also as root create a file index.php inside it with the following contents:<?php
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/mythweb/');
you’ll need to restart apache for the httpd.conf modifications, as well as opening the port to the internet in iptables and restarting that. then visit your server on that port and you’ll get bumped to /mythweb/ and asked for a password.
sadly it still doesn’t work because php removed support for some bad coding that mythweb was using. to fix it, edit
/usr/share/mythtv/bindings/php/MythBase.php as root, go to line 50 and remove the & in front of $this so it looks this way:
/var/www/html/mythweb/includes/sorting.php go to line 122 and remove the & from $a and $b to get this:
/var/www/html/mythweb/modules/tv/tmpl/default/schedules.php go to line 88 and insert the following line:
add that same line to [/var/www/html/mythweb/modules/tv/schedules.php[/code] before line 50.
now that mythtv is recording to a directory shared through samba and mythweb is working, you can install mythtv recorded programs on any windows machines where you’d like to watch recordings from mythtv.