Skip to content

Lighttpd and MythTV

I came across a problem while using my MythTV box. I decided that I would like to be able to download the mpegs onto my desktop. I have issues watching the shows using MythFrontEnd on my G4 powerbook over wireless. So, downloading the files and watching them with VLC was my next step.

So, what was the best way to download files? I set up both ftp and samba. They were both a bit hokey because I really have to rename all of the files so that they make sense. Plus, I am not sure if they are the most efficient ways to transfer files. What I really wanted to do was to browse to the file using MythWeb and then download them from there. Then I can see the descriptions, time recorded, etc. … The only problem was Apache. Most of my files are over 2GB. A one hour show generally is 2.2GB on my box. I always got an error when I tried to download a show. Unfortunately, Apache 2.0 on my Ubuntu box has 32bit issues when dealing with large files. I use Ubuntu 5.10 (Breezy) as my Myth box. (For a good resource on setting this up check out this page.)

The solution to my problem was a different web server called Lighttpd.

I really did not want to get rid of my existing stock Apache installation. I suppose, in retrospect, I could have just installed a new version of Apache (which does support greater than 2GB files) from source and run them concurrently. However, I like to make my life more difficult, so I decided to look at Lighttpd. Lighttpd does support greater than 2GB files. The big question was, will it work with MythTV?

So, the first thing I did was see if MythWeb will even run on anything besides Apache. Fortunately for me, someone did write up a Wiki article on it located here. So, I knew it was possible. The question was, could I get it working on my system.

The next step I looked at was what were my options for getting Lighttpd installed on my system. Unfortunately, it did not look like Ubuntu had ported it over yet. There is a version for newer Ubuntu systems, but since mine is about 9 months old, I was out of luck. So, the next thing was to build it from source.

Now, usually these days, building from source is as simple as ./configure;make;make install. However, I really wanted to build a package so I could use apt to manage it. I found one web site that described the process. However, it pointed somewhere else for a patch that no longer existed.

So, I ended up following the instructions on the Lighttpd Trac. I followed the instructions for building it from source for Debian (since Ubuntu is from Debian). The kicker here is to download both the newest version and an older version. This is done so you can copy the debian directory from the older version into the newer version. So, instead of using the standard ./configure… sequence, now I can simply do dpkg-buildpackage. This builds a package which I can then install by typing dpkg -i lighttpd-1.4.VERSION.deb.

So, now I have Lighttpd installed. Now what? Well, first I had to configure it and start it up. All of the config files are located in /etc/lighttpd. Basically, it is one file called lighttpd.conf. So, here is where I started following the directions on the MythWeb Wiki article mentioned above. Note, that I had to use his “hacked” way of doing things. However, because I am running Ubuntu, there are some major differences between what he uses vs. what I use. The first thing that I notice is that he starts talking about fastcgi. Well, I know that my php4 installation does not run via cgi on my existing apache installation. So, I had to figure out what to do about that. This is a simple remedy. You just type apt-get install php4-cgi. This installs the cgi portion of php4.

Now, because I am running Ubuntu, my paths are different. So, my bin-path variable is “/usr/bin/php-cgi” not “/usr/local/bin/php”. Other minor changes I made were changing my server.document-root to “/var/www/mythweb” from the stock variable and changing my port to 81 so it would not conflict with my existing apache installation (if you don’t care, you can put to 80 so that it is standard). Another change I added was to add “mythweb.php” to the list of server.indexfiles. This way, when I when I pointed my browser to http://SERVERNAME:81, my mythweb installation will automatically come up.

Now, if you have followed along with the Wiki and my changes, you should be able to see the MythWeb initial page after you start up the web server. This indicates that Lighttpd and PHP are working and connecting to the database. However, you will notice that you cannot click on any other pages without an error.

To solve this problem requires changing some parameters in the PHP setup. This file is located at /etc/php4/cgi/php.ini. The main change I made was to change the default of cgi.fix_pathinfo from its default of 0 to 1. I also added a blank docroot line (I uncommented it), however, I do not think that this impacted anything. Once, I did this I was now able to click on links and bring up the proper pages. Everything seems to be funtioning correctly.

So, ultimately, we come back to the original problem. Can I download large files via http? So, I clicked on the Recorded Programs link, picked a show I wanted, right clicked on it, selected save the linked file as, hit ok, and yes, it is downloading.

Now, I have a web server sitting on port 81 in addition to my stock Apache sitting on port 80 in which I can download large files. If you don’t need your stock Apache server, I would just disable and move Lighttpd back to port 80.

Post a Comment

You must be logged in to post a comment.