ruby 1.9.3 for Debian Squeeze

# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm –no-ri –no-rdoc

apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
time (./configure –prefix=/usr && make && make install DESTDIR=/tmp/ruby193)

/var/lib/gems/1.8/bin/fpm -s dir -t deb -n ruby193 -v 1.9.3-p125 –description “Self-packaged Ruby 1.9.3 patch 125” -C /tmp/ruby193 \
-p ruby193-VERSION_ARCH.deb -d “libstdc++6 (>= 4.4.3)” \
-d “libc6 (>= 2.6)” -d “libffi5 (>= 3.0.4)” -d “libgdbm3 (>= 1.8.3)” \
-d “libncurses5 (>= 5.7)” -d “libreadline6 (>= 6.1)” \
-d “libssl0.9.8 (>= 0.9.8)” -d “zlib1g (>= 1:1.2.2)” \
-d “libyaml-0-2 (>= 0.1.3)” \
usr/bin usr/lib usr/share/man usr/include

# Post installation test
apt-get remove ruby rubygems
apt-get install libffi5 libyaml-0-2
dpkg -i dpkg -i ruby193-1.9.3-p125_amd64.deb
ruby -ropenssl -rzlib -rreadline -ryaml -e “puts :success”

credit:
https://gist.github.com/futuremill/2318876

no JDK found – please set JAVA_HOME … failed!

แก้ไข

/etc/bash.bashrc

เพิ่ม

#Java Environment Variable
JAVA_HOME=/usr/lib/jvm/jdk1.7.0/
export JAVA_HOME
JRE_HOME=/usr/lib/jvm/jdk1.7.0/jre
export JRE_HOME
PATH=$PATH:$JAVA_HOME:$JRE_HOME
export PATH

ถ้าเป็น JAVA 8

#Java Environment Variable
JAVA_HOME=/usr/lib/jvm/jdk1.8.0/
export JAVA_HOME
JRE_HOME=/usr/lib/jvm/jdk1.8.0/jre
export JRE_HOME
PATH=$PATH:$JAVA_HOME:$JRE_HOME
export PATH

favicon.ico with Nginx

ท่าานเจอกับปัญหา nginx error log โชว์แต่ error ว่าไม่พบ favicon.ico ใช่หรือไม่?

2013/03/27 14:48:45 [error] 7924#0: *2436 open() “/home/nginx/activity.xxx.com/htdocs/favicon.ico” failed (2: No such file or directory), client: 119.44.16.42, server: activity.xxx.com, request: “GET /favicon.ico HTTP/1.1”, host: “praew.xxx.com”
2013/03/27 14:48:48 [error] 7924#0: *2436 open() “/home/nginx/activity.xxx.com/htdocs/favicon.ico” failed (2: No such file or directory), client: 119.44.16.42, server: activity.xxx.com, request: “GET /favicon.ico HTTP/1.1”, host: “praew.xxx.com”
2013/03/27 14:48:50 [error] 7924#0: *2436 open() “/home/nginx/activity.xxx.com/htdocs/favicon.ico” failed (2: No such file or directory), client: 119.44.16.42, server: activity.xxx.com, request: “GET /favicon.ico HTTP/1.1”, host: “praew.xxx.com”

ทางแก้คือ.. บอกให้ nginx ส่งค่า 204 ไปยัง browser ครับ

nginx.conf

http {
....
...
..
.
server {
        location = /favicon.ico {
                return 204;
                access_log     off;
                log_not_found  off;
                }
        }
}

epeg VS imagemagick

คือแบบว่า imagemagick มันช้าครับ
เลยต้องหาวิธีที่จะ convert ได้ไวไว เลยไปเจอกับ epeg

# git clone git://github.com/mattes/epeg.git
# aptitude install build-essential cdbs debhelper libjpeg62-dev automake 
# ./configure
# make 
# make install
# cp src/lib/.libs/libepeg.so* /usr/lib/

ทดสอบการใช้งาน

root@server:# time convert -resize 230 london-hq-sunny.jpg london-hq-sunny_230.jpg 

real	0m0.889s
user	0m0.336s
sys	0m0.032s

root@server:#  time epeg -w 230 -h 144 london-hq-sunny.jpg london-hq-sunny_230.jpg

real	0m0.016s
user	0m0.004s
sys	0m0.012s

เร็วสุดชีวิต!

ref:
http://superuser.com/questions/249646/fastest-jpeg-thumbnail-generator-for-linux