Jun 9, 2010

Lighttpd PHP fastcgi configuration

Install lighttpd

# yum install lighttpd
# yum install lighttpd-fastcgi


Make sure php support fastcgi

$ php-cgi -v

PHP 5.0.4 (cgi-fcgi) (built: Nov 8 2005 08:25:54)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies


Open lighttpd configuration file:

# vi /etc/lighttpd/lighttpd.conf

server.modules = (
"mod_access",
"mod_accesslog",
"mod_fastcgi",
"mod_rewrite",
"mod_auth"
)


Add the following lines:

fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
)))


Restart the lighttpd server

# /etc/init.d/lighttpd restart

Jun 1, 2010

Bash programming.

Manipulation of number

total=`expr ${total} + ${pathsize}

let sum=0
let sum=$sum+$num


Testing Using While loop.

#!/bin/bash
COUNT=6
# bash while loop
while [ $COUNT -gt 0 ]; do
echo Value of count is: $COUNT
let COUNT=COUNT-1
done


Calculating the Date Modified
Sample Code:

CUR_DATE=$(date +"%s");
for JOB_FILE in [0-9]*; do
MOD_FILE_DATE=$(stat -c "%Y" $JOB_FILE)
echo -e "$JOB_FILE\t$CUR_DATE\t$MOD_FILE_DATE"
done

Or

if [ "$(( $(date +"%s") - $(stat -c "%Y" $somefile) ))" -gt "7200" ]; then
echo "$somefile is older then 2 hours"
fi

VIM Command


http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html

Encoding String using BASH


OUTPUT=$(php -r "echo rawurlencode('$(sed "s/'/\\\\'/g" <<< "$OUTPUT")');")


Getting Absolute File Path


Originally FROM: how-to-get-the-absolute-path-within-the-running-bash-scrip

# Absolute path to this script. /home/user/bin/foo.sh
SCRIPT=$(readlink -f $0)
# Absolute path this script is in. /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`


Multi di-mentional ARRAY



#!/bin/bash
A=("abcd" "dcba")
Z=("zxyw" "wxyu" "tuxz")
ARR=(A Z)

for ROW in ${ARR[*]}
do
echo "processing row: $ROW"
TEMP="\${$ROW[*]}"
ROW=`eval echo $TEMP`
for ELEMENT in $ROW
do
echo " processing element: $ELEMENT"
done
done

Original Post:bash-multidimensional-array

Bash : converting unix timestamp to date


converting unix timestamp to date