Build Your Own Video Community With Lighttpd And FlowPlayer (Debian Lenny) - Page 2

6 Configuring Lighttpd

Now we have to open lighttpd's main configuration file, /etc/lighttpd/lighttpd.conf, and add/enable the modules mod_secdownload and mod_flv_streaming in it. It is very important that mod_secdownload is listed before mod_flv_streaming in the server.modules stanza. When I did it the other way round, I found that fast-forwarding the video in FlowPlayer didn't work!

vi /etc/lighttpd/lighttpd.conf
server.modules              = (
#           "mod_rewrite",
#           "mod_redirect",
#           "mod_evhost",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_webdav",
#           "mod_expire",
#           "mod_evasive"

In the same file, we add also add the following configuration (you can add it right at the end of /etc/lighttpd/lighttpd.conf):

flv-streaming.extensions = ( ".flv" )
secdownload.secret          = "somesecret"
secdownload.document-root   = "/var/videos/flv/"
secdownload.uri-prefix      = "/dl/"
secdownload.timeout         = 120

Please replace somesecret with your own secret string (you can choose one).

What mod_secdownload does is this: a web application (e.g. a PHP script) can have a link in it of the following form:




where <token> is an MD5 of

  1. a secret string (user supplied)
  2. <rel-path> (starts with /)
  3. <timestamp-in-hex>

mod_secdownload will then map this link to the appropriate file in the secdownload.document-root (which is outside the document root of the web site) and allow access to that file for secdownload.timeout seconds. After secdownload.timeout seconds, the link isn't valid anymore, and access is denied.

After we have installed FlowPlayer, we will use a PHP script to generate the appropriate video links for mod_secdownload.

You can find more information about mod_secdownload here:

Don't forget to restart lighttpd after your changes to /etc/lighttpd/lighttpd.conf:

/etc/init.d/lighttpd restart


7 Installing FlowPlayer

Go to and download the latest FlowPlayer version to your /tmp directory, e.g. like this:

cd /tmp

FlowPlayer comes in .zip format, so we must install unzip to uncompress it:

aptitude install unzip

Afterwards we can uncompress it:


This creates a directory called flowplayer in the /tmp directory. I'd like to have that directory in the document root of my video web site (/var/www), so I move it there:

mv flowplayer /var/www/


8 Configuring FlowPlayer

FlowPlayer is now installed, so all that is left to do is create an HTML file that lets us watch our video. I will create a PHP file for this called /var/www/flowplayertest.php which contains all parameters to start FlowPlayer in the user's browser and which also creates valid video links for mod_secdownload:

vi /var/www/flowplayertest.php

$secret = "somesecret";
$uri_prefix = "/dl/";

# filename
$f = "/video.flv";

# current timestamp
$t = time();

$t_hex = sprintf("%08x", $t);
$m = md5($secret.$f.$t_hex);

<title>Flowplayer Test</title>

<script src="/flowplayer/example/flowplayer-3.1.4.min.js"></script>

<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">

    href="<?php printf('%s%s/%s%s', $uri_prefix, $m, $t_hex, $f, $f); ?>"

<script language="JavaScript">
flowplayer("player", "/flowplayer/flowplayer-3.1.5.swf");


It's very important that $secret has the same value than secdownload.secret in /etc/lighttpd/lighttpd.conf. Also, $uri_prefix and secdownload.uri-prefix must match. If this is fulfilled, the above script will generate valid links. $f must hold the filename of the FLV video, beginning with a slash (/). (The filename is hard-coded in the above example, but of course you can program whatever you like to dynamically generate the filename.)

The important parts that call FlowPlayer are <script src="/flowplayer/example/flowplayer-3.1.4.min.js"></script> (which refers to the flowplayer-3.1.4.min.js script in the /var/www/flowplayer/example directory) in the <head></head> section and the following two parts in the <body></body> section:

    href="<?php printf('%s%s/%s%s', $uri_prefix, $m, $t_hex, $f, $f); ?>"

(The most important setting is the href parameter (which is set by PHP in the above script) which specifies the path to the FLV video. In the style parameter, we can specify the width and height of our video player.)


<script language="JavaScript">
flowplayer("player", "/flowplayer/flowplayer-3.1.5.swf");

(Here we specify the path to our FlowPlayer .swf file.)

This FlowPlayer configuration is taken from

To learn more about other ways of calling FlowPlayer and how to call it with specific settings, take a look at the examples on

Now it's time to test our setup. Direct your browser to or, and your video should start to play in your browser (including sound):

This is how the native Flash 9 full screen mode looks:


Share this page:

0 Comment(s)