Skip to main content

Posts

Showing posts from November, 2012

Configuration of Nginix Virtual Host

Right, they don't call it virtual box here. They call it server block. Anyway, below file runs two websites as virtual host:

Website name:  n123test.com and multi32.com

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

server {
    listen       80;
#    listen       *:80;
    server_name  n123test.com;

    location / {
        root  /var/www/ntest/public_html;
        index  index.html index.htm;
    }
}



server {
    listen       80;
#    listen       *:80;
    server_name  multi32.com;

    location / {
        root  /var/www/multi32/;
        index  index.html index.htm;
     }
 }

Example File of Fsniper Config File

watch {

    # watch the ~/drop directory for new files
    ~/one {
        # matches any mimetype beginning with image/
        image/* {
            # %% is replaced with the filename of the new file
            handler = echo found an image: %%
        }

        # matches any file ending with .extensio

        *.txt {
            # the filename is added to the end of the handler line if %% is not present
handler = /bin/sh %% ; cp ~/one/*.txt ~/two
            # the second handler will be run if the first exits with a return code of 1
            handler = echo glob handler 2: %%
        }

        # run handlers on files that match this regex
        /.*regex.*/ {
            handler = echo regex handler
        }

        # generic handler to catch files that nothing else did
        * {
            handler = mv %% ~/downloads/
        }
    }

}





##############################################################################

What does it do?

The text in blue actually does the trick.

Installing & Configuring Fsniper ( Advanced Topics)

Did some one said that what is fsniper? Great, it is a software that can detect any change in your directory. Installing fsniper is easy, configuration is not. So I am providing you what to do step by step.

1. Installation:

Download fsniper.

Now you have to compile it.

Make sure gcc and make is installed ( yum install gcc and yum install make)

Now ./configure
make
make install

2. Configuration:

in /etc/init.d
put fsniper file

for fsniper file see http://pc2solution.blogspot.in/2012/11/fsniper-file-to-be-put-in-etcinitd.html

3.

in ~/.config/fsniper/
put config ( config is actually rename file of example.conf)

4.


Kill fsniper process if running,

then run #fsniper --daemon

service fsniper restart.

If you service is started, and you see OK then you are done.

Fsniper file to be put in /etc/init.d

export HOME=/root

case "$1" in
start)
echo -n "Starting Fsniper: "
/usr/local/bin/fsniper --daemon
echo -e "... [ \e[00;32mOK\e[00m ]"
;;
stop)
echo -n "Shutdown Fsniper: "
kill -9 `ps aux | grep "fsniper --daemon" | grep -v grep | awk {'print $2'}`
echo -e "... [ \e[00;32mOK\e[00m ]"
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart"
exit 1
esac

exit 0





#################  for full configuration see http://pc2solution.blogspot.in/2012/11/installing-configuring-fsniper-advanced.html