First we need to install and configure lighttpd,php5 and Mysql on our uubntu system so as to setup our streaming or video community.Lighttpd is a secure, fast, standards-compliant web server designed for speed-critical environments.
sudo apt-get install mysql-server mysql-client
you will be promted for password for the root user two times..
you can check the mysql installation by issuing this command on terminal
mysql -u root -p
sudo apt-get install lighttpd
After installation you check whether the webserver is working by opening a browser and pointing the url to http://127.0.0.1 or http://localhost
Lighttpd’s default document root is /var/www on Ubuntu, and the configuration file is /etc/lighttpd/lighttpd.conf
sudo apt-get install php5-cgi
To enable PHP5 in Lighttpd, we must modify /etc/php5/cgi/php.ini and add the line cgi.fix_pathinfo = 1 right at the end of the file or if you search this cgi.fix_pathinfo in the file you can see it is commented uncomment it or add the line.
To enable the fastcgi configuration run the following command
ls -l /etc/lighttpd/conf-enabled
Reload lighttpd using this command
Test php5 installation
The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.
sudo vim /var/www/info.php
Paste this code in that php file to get information
Now we call that file in a browser
You will get information like this
Getting MySQL Support In PHP5
We need some file to be instaled in order to get mysql support in php issue this command on terminal
sudo apt -get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json
Now restart lighttpd
Now if you got to info.php you can see mysql is also listed in it.
Setting up streaming server or video community
this is needed we need to convert avi files to flv etc
sudo apt-get nstall flvtool2 ffmpeg
Creating Video Directories
This is the location where videos are stored .I directly copied a youtube video from firefox cache and renamed it to flv if you have a custom video convert it to flv using any converteror using ffmpeg and flvtool that we previously installed.
mkdir -p /var/videos/flv
sudo vim /etc/lighttpd/lighttpd.conf
Now we have to open lighttpd’s main configuration file, /etc/lighttpd/lighttpd.conf, and add/enable the modules mod_secdownload andmod_flv_streaming in it. It is very important that mod_secdownload is listed before mod_flv_streaming in the server
server.modules = (
Also add thos at the end of the configuration file
flv-streaming.extensions = ( ".flv" )
secdownload.secret = "mysecretcode"
secdownload.document-root = "/var/videos/flv/"
secdownload.uri-prefix = "/dl/"
secdownload.timeout = 120
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
- a secret string (user supplied)
- <rel-path> (starts with /)
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 forsecdownload.timeout seconds. After secdownload.timeout seconds, the link isn’t valid anymore, and access is denied.
Now we will download and extract the flowplayer from its site and will move the extracted folder to /var/www
mv flowplayer /var/www/
Now createa phpscript
sudo vim /var/www/flowplayertest.php
This is the content of the script
$secret = "mysecretcode";
$uri_prefix = "/dl/";
$f = "/video.flv";
# current timestamp
$t = time();
$t_hex = sprintf("%08x", $t);
$m = md5($secret.$f.$t_hex);
<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); ?>"
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.
Now restart lighttpd and point your webbrowser to http://localhost/flowplayertest.php
you will get an output like this trobleshooting can be done by reading the access and error logs og lighttpd
sudo tail -f /var/log/lighttpd/access.log
sudo tail -f /var/log/lighttpd/error.log
The output in browser will look like this..