Reload Gnome panels without restarting the system

Sometine the gnome panel may get buggy and becomes irresponsive…..it shows all the closed windows also in the panel…at that times we can reload the panel without rebooting the system…Use the Alt+F2 key combination to bring up the Run dialog, and then enter in this command:

killall gnome-panel

This restarts the gnome-panel

Advertisements

Directory size excluding sub-directories – Linux

To find the size of a directory which has several sub directories can be done by using the following command

du  -skh  /home/user

please note the “s” here used is lower case  if we use upper case then it will list size of all sub directories too….replace the /home/user with your folder name..

you can also use this command  to find total space used

du -ch | grep total

How to Enable clean urls in drupal 6.xx and lighttpd

To enable clean url in drupal when we use lighttpd as webserver it needs a small hack…

we need to edit the configuration file ( /etc/lighttpd/lighttpd.conf) .In the server modules “mod_rewrite” must beenabled else edit it to the same.After editing server modules look like this

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_flv_streaming",
#           "mod_evasive"
            "mod_secdownload",
            "mod_flv_streaming",
)

Then add this bunch of code to the lighttpd.conf file

url.rewrite-final = (
  "^/system/test/(.*)$" => "/index.php?q=system/test/$1",
  "^/system/test-clean-url/(.*)$" => "/index.php?q=system/test-clean-url/$1",
  "^/drupal/([^.?]*)\?(.*)$" => "/drupal/index.php?q=$1&$2",
  "^/drupal/([^.?]*)$" => "/drupal/index.php?q=$1",
  "^/drupal/search/(.*)$" => "/drupal/index.php?q=search/$1",
   "/drupal/rss.xml$" => "/drupal/index.php?q=rss.xml"
)
#url.rewrite-if-not-file = (
#    "^\/([^\?]*)\?(.*)$" => "/newone/index.php?q=$1&$2",
#    "^\/(.*)$" => "/newone/index.php?q=$1"
#)

Rename the drupal with the name of your folder in the code

Flv streaming using lighttpd and flowplayer in Ubuntu 10.04

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.

Install Mysql

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

Install Lighttpd

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

Install Php5

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

/etc/init.d/lighttpd force-reload

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

 http://localhost/info.php

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.

 http://localhost/info.php

Setting up streaming server or video community

Installing flvtool2

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

Configuring Lighttpd

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:

<uri-prefix>/<token>/<timestamp-in-hex>/<rel-path>

e.g.

/dl/d8a8cb150f7e5962f6a8443b0b6c6cc2/46c1d9f6/video.flv

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 forsecdownload.timeout seconds. After secdownload.timeout seconds, the link isn’t valid anymore, and access is denied.

/etc/init.d/lighttpd restart

Installing FlowPlayer

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/

 

Configuring FlowPlayer

Now createa phpscript

sudo vim  /var/www/flowplayertest.php

This is the content of the script

<?php

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

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

# current timestamp
$t = time();

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

?>
<html>
<head>
<title>Flowplayer Test</title>

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

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

<a
    href="<?php printf('%s%s/%s%s', $uri_prefix, $m, $t_hex, $f, $f); ?>"
    style="display:block;width:320px;height:256px;"
    id="player">
</a>

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

</body>
</html>

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..