Thursday, 23 May 2013

linux set ulimit

for setting ulimit u need to run following command

ulimit -n  10000  for setting limit to 10000

for soft files  
ulimit -Sn  10000

and for hard files
ulimit -Hn 10000


do it individually for all users

and this setting will be vanished after system restart

Saturday, 20 April 2013

virtual hosting in nginx

Virtual hosting in nginx is very simple :

see nginx.conf file 

one server block is generally available there .
see


server {
listen 80;
server_name _;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
   /root //html;
  index index.html index.htm index.php ;
}
}


this is default server setting. that means from all doamains this will work .

for virtual hosting define new server block 
 

:
server {
listen 80;
  server_name yourdomain.com;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
   /root /new_host;
  index index.html index.htm index.php ;
}
}





now settings have been changed

just restart nginx  and see
if traffic coming from  yourdomain.com  then it will point to /root/ new_host   directory .

else it will go to /root/html  directory and find related contents here.




thats it   . it was very simple



ask me if u want any further help .


Saturday, 13 April 2013

php call method froma string with parameters

very simple way to do that 


function abcd($parameter)
{
     return ture ;
}

$meth_str="abcd('ab')";
$res = false;
        $abc = '$res';
        $check = <<<bcd
if($meth_str)
{
        $abc= true;
} else
{
        $abc=false;
}
bcd;

        eval($check.";");    ///   that means $res=true;
     

Hope it helps
if need further help  comment here 


php check if IP lies in IP Range



first write function to check ip range

function Iprange_testing($iprange, $iptocheck)
{

    $ip = $iptocheck;


        list ($ip1, $ip2) = explode('-', $iprange);
        $ips = Array($ip,$ip1,$ip2);
        // sort ips and check if client ip is middle one
        natsort($ips);

        $sorted=implode("-", $ips);
        $ips=explode("-", $sorted);

        $ipcheck = true;

        if ($ips[1]!=$ip)
        {

            $ipcheck=false;
        }
return $ipcheck ;
    }

Now call this method

$res1  = Iprange_testing('192.168.1.10-192.168.1.100', '192.168.1.50');  //returns ture
$res2  = Iprange_testing('192.168.1.10-192.168.1.100', '192.168.1.101');  //returns false