Saturday, July 20, 2013

installing nginx

sudo yum install gcc
sudo yum install make
sudo yum install pcre-devel
sudo yum install zlib-devel

wget nginx-x.x.x.tar.gz from nginx.org

tar -xvzf nginx-x.x.x.tar.gz

./configure --prefix=/opt/nginx

make

sudo make install

sudo /opt/nginx/sbin/nginx -c <location to conf>/conf/nginx.conf

copy conf directory from the nginx download to home directory

Note: make sure that in the conf the user is known user, 'nobody' is the default user and which would have permission issues to access files.

Friday, July 6, 2012

bounce php-fpm

To stop

killall -w -v php-fpm

-w is to wait for the processes selected to stop
-v verbose

I observed that few php-fpm processes took time to stop (might be they are wrapping up stuff). Immediately starting php-fpm after passing the killall command without -w might cause error (port in use or unix socket in use).

Another important point. In case if you are running php-fpm in the unix socket mode then make sure to bounce your server in case you are bouncing php-fpm. I follow this

stop server && stop php-fpm && start php-fpm && start server

Sunday, April 1, 2012

SQL- distinct

select distinct city, college_name from students

> so the combination of city and college should be distinct we can not have it like

select city, distinct college_name from students

but we can have it with an aggregate e.g. for each city give me the count of distinct colleges :) eh!

select city, count(distinct college_name) from students

postgres - from clause in update sql

update students set college_name = c.name from colleges c
where students.city = c.city

weired SQL but awesome isn't??!!

> In update we cannot use aliases for the update table so have to use the full name in case of ambiguous columns e.g. city

> we can have any number of from tables with aliases and have a join on the update table and also can update a value using a value from the join table

Monday, March 5, 2012

SQL: exists

Today I figured out that we can use sql "exists" in the select part of a query

e.g. select name, exists (select 1 from girls where bf_name = boys.name) has_bf from boys b

result:
name has_bf
------------
A t
B f
C t

Monday, February 6, 2012

SOAP and PHP

Calling a SOAP based service could not be this easy as it can be done with PHP
        $objClient = new SoapClient("http://foobar.in/services/blahblah?wsdl", array('trace' => true));
    
        $objResponse = $objClient->getGreeting(array("name" => "tom"));
    
        //print($objClient->__getLastRequest());        
        print_r($objResponse);
$objResponse
stdClass Object
(
    [out] => stdClass Object
        (
            [message] => Hello tom!
        )
)

Friday, November 11, 2011

Installing PNP


I am working on Ubuntu (Debian)

echo 'Installing PHP...';
sudo apt-get install --yes --force-yes php5-cli php5-dev php5-fpm php5-pgsql php5-mcrypt php5-gd php5-curl php-pear

echo 'Installing nginx...';
sudo apt-get --yes --force-yes install nginx


echo 'Installing Postgres...';
sudo add-apt-repository ppa:pitti/postgresql
echo 'Updating...';
sudo apt-get --yes --force-yes update
echo 'Upgrading...';
sudo apt-get --yes --force-yes dist-upgrade
echo 'Installing postgres...';
sudo apt-get --yes --force-yes install postgresql-plpython-9.1