Bash scripts

Change upper case to lower case

#echo ‘TEST’|/usr/bin/tr -s ‘[:upper:]’ ‘[:lower:]’
test

Work with array

IFS=$’\n’ ##here tells how to devide the output, default is space
##but I want to put each line into a array
files=($(ls ./) ##put file names into an array using ()
for (( i=0;i<${#files[@]};i++ ));do mv $files[$i] $files[$i]_OLD done

Match pattern

if [[ $string =~ “data” ]];do
echo “$string contains data”
done

Enable status in PHP-fpm + Nginx

It was a little bit confusing to set it up. So here’s the memo.

vi /etc/php5/fpm/pool.d/www.conf

pm.status_path = /status
listen = 127.0.0.1:9000

vi /etc/nginx/sites-available/monitor
location ~ ^/(status|ping)$ {
include fastcgi_params;
#access_log off;
allow 127.0.0.1;
allow xx.xx.xx.xx;
deny all;
fastcgi_param SCRIPT_FILENAME /status;
fastcgi_pass 127.0.0.1:9000;
}

Restart nginx and php-fpm processes.

Ref: Here