News for the ‘how-to’ Category

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;
                }
        }
}
Posted: March 27th, 2013
Categories: how-to, linux
Tags: ,
Comments: No Comments.

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

Posted: March 18th, 2013
Categories: how-to, linux
Tags: ,
Comments: No Comments.

Argument list too long

ปัญหาแบบนี้

$ mv item_display/* ../item_display/
bash: /bin/mv: Argument list too long

แก้โดย

find /path/to/file -type f | xargs -i mv “{}” /path/to/move

หรือ

find /path/to/file -type f -name '*' -exec mv {} /path/to/move/. \;

หรือแบบยากๆเลย

http://www.linuxjournal.com/article/6060

Posted: March 18th, 2013
Categories: how-to, linux
Tags: ,
Comments: No Comments.

register_globals in drupal

เมื่อติดตั้ง drupal แล้วเจอปัญหาว่า

Requirements problem
The following error must be resolved before you can continue the installation process:
register_globals is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when register_globals is enabled. The PHP manual has instructions for how to change configuration settings. (Currently using PHP register globals Enabled (’1′))

แก้ได้ด้วยตัวเองโดยไม่ต้องบอกให้ system admin แก้ไขระบบ ด้วยการ

สร้าง php.ini ไว้ที่ root document โดยมีข้อมูลข้างใน คือ

 
[PHP]
register_globals = Off

ref :
http://drupal.org/node/216882

Posted: March 17th, 2013
Categories: how-to, linux
Tags: ,
Comments: No Comments.

NginX rewrite rules for WordPress on subdirectory

   location /wordpress {
                try_files $uri $uri/ /wordpress/index.php?$args;
        
        location ~ \.php$ {
                fastcgi_split_path_info ^(/wordpress)(/.*)$;
        }
   }

via :
http://wiki.nginx.org/WordPress
http://codeblow.com/questions/nginx-wordpress-inside-a-subdirectory-what-data-ought-to-be-passed/

Posted: March 13th, 2013
Categories: how-to, linux
Tags: ,
Comments: No Comments.