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
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
lighttpd-enable-mod fastcgi 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
<?php phpinfo(); ?>
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 = ( "mod_access", "mod_alias", "mod_accesslog", "mod_compress", # "mod_rewrite", # "mod_redirect", # "mod_evhost", # "mod_usertrack", # "mod_rrdtool", # "mod_webdav", # "mod_expire", "mod_secdownload", "mod_flv_streaming", # "mod_evasive" )
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
wget http://releases.flowplayer.org/flowplayer/flowplayer-3.1.5.zip unzip flowplayer-3.1.5.zip mv flowplayer /var/www/
Now createa phpscript
sudo vim /var/www/flowplayertest.php
This is the content of the script
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..