Thursday, 3 November, 2011

Berkeley DB Useful Commands

To create the database.  Create a text file, name it a.txt,
which has keys and values like this:
key_0
value_0
key_1
value_1

Run:

 $ db_load -T -t hash -f a.txt a.db

Tuesday, 27 September, 2011

the best vnc viewer

This is the best vnc viewer I have ever seen.  It's Enhanced VNC Thumbnail Viewer : http://sourceforge.net/projects/evnctv/

Saturday, 13 August, 2011

undefined symbol: ap_cache_cacheable_hdrs_out

After enabling mod_mem_cache, I encountered these errors when restarting apache:
 
* Restarting web server apache2
 * We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!
 ... waiting apache2: Syntax error on line 204 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/mem_cache.load: Cannot load /usr/lib/apache2/modules/mod_mem_cache.so into server: /usr/lib/apache2/modules/mod_mem_cache.so: undefined symbol: ap_cache_cacheable_hdrs_out
   ...fail!

Just put:

LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so

before:

# Include module configuration:

in:

/etc/apache2/apache2.conf

And it's fixed!

Saturday, 6 August, 2011

เวลาต้องห้ามในการตั้งให้ cronjob ทำงาน

ห้ามตั้งเวลา cronjob ระหว่าง ตีสองถึงตีสาม เพราะจะมีวันนึงที่ไม่ทำงานและจะมีวันนึงที่ทำงานสองรอบ หากมี daylight saving

http://en.wikipedia.org/wiki/Daylight_saving_time

Wednesday, 20 July, 2011

แผนยึดครองโลกของตำรวจโลก

... to be continued ...

Google products often choose Thai interface for me and this is the real problem

Can I call it a "bug"?  This is far too annoying.  Yes, I am THAI and my English is not that good BUT the Thai interface SUCKS.  I should have right to choose which Language I prefer.  There is no obvious place where I can set it.  Some products have, some don't.

Fortunately, people find a way to change the interface language by appending these 2 HTTP GET variables depending on the URL you are seeing:

&hl=en
?hl=en

Note that it will only work with your current session.  If you come back later, you may need to do it again.  You should have a real fix for this, Google.

grep out the process called httpd without including the grep command itself in the output

ps auxw | grep "[h]ttpd" # grep out the process called httpd without including the grep command itself in the output (via climagic)

Tuesday, 12 July, 2011

cannot run screen after su -

This error message:

Cannot open your terminal '/dev/pts/0' - please check.

occurs when you try to run screen after you "su -" to someone else.  You can skip this error by:

script -c "screen -S main" /dev/null

Friday, 8 July, 2011

how to set up vsftpd with pam authentication for name-based virtual hosting

I was surprised how vsftpd didn't work out of the box to support authentication without unix system account.  It took me 2 days to research and did trial and error before I could make it work.  Here is the result.

system: debian

# apt-get install libpam-pwdfile
# mkdir /etc/vsftpd
# cd /etc/vsftpd
# htpasswd -c passwd_ftp a_sample_website

Here I assume that the root directory of your virtual host is /vhdocs/a_sample_website/.

# cd /etc/pam.d
# vi vsftpd

Make sure it looks exactly like this:

# Standard behaviour for ftpd(8).
auth    required        pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own.  Do not enable
# pam_ftp.so.

# Standard blurb.
#@include common-account
#@include common-session

#@include common-auth
#auth   required        pam_shells.so

# Customized login using htpasswd file
auth    required pam_pwdfile.so pwdfile /etc/vsftpd/passwd_ftp
account required pam_permit.so

Then edit vsftpd's config file:

# vi /etc/vsftpd.conf

It is a long config file.  I will tell you only required lines:

write_enable=YES
local_umask=022
chroot_local_user=YES
# addtitional settings by chaitat
virtual_use_local_privs=YES
connect_from_port_20=YES
guest_enable=YES
guest_username=ftp
user_sub_token=$USER
local_root=/vhdocs/$USER
hide_ids=YES

Restart vsftpd:

# /etc/init.d/vsftpd restart

Modify files' owner:

# chown -R ftp.nogroup /vhdocs/a_sample_website

--
unsigned_nerd

Thursday, 7 July, 2011

.htaccess and .htpasswd

sample .htaccess and .htpasswd

.htaccess

AuthUserFile /var/www/tmp/.htpasswd
AuthName "My Private Directory"
AuthType Basic
require valid-user

.htpasswd

admin:$apr1$Y5J7envl$dYoDhqywTT.mD4L6MQIAU/