2012年1月7日 星期六

postgresql 安裝

# apt-get install postgresql php5-pgsql
# apt-get install postgresql postgresql-client postgresql-contrib
# apt-get install pgadmin3
 
// setting up the server for remotely access
# vi /etc/postgresql/8.2/main/postgresql.con
listen_addresses = '*'
password_encryption = on
// Secure the postgresql database with an admin password.
$ sudo -u postgres psql template1
# ALTER USER postgres WITH PASSWORD 'NewAdminDatabasePassword';
# \q

// change the words ident sameuser to md5 
# vi /etc/postgresql/8.4/main/pg_hba.conf
# Database administrative login by UNIX sockets 
local all postgres md5
local all all md5
# add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server  84 host
all         all         138.250.192.115/24          md5

# /etc/init.d/postgresql restart


// create database user
$ sudo -u postgres createuser -D -A -P testuser 
  
// create database
$ sudo -u postgres createdb -E utf8 -O testuser testdb
 
 
// set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmi 
$ sudo su postgres -c psql < /usr/share/postgresql/8.3/contrib/adminpack.sql
 
 
 

Reference :
PostgreSQL with PHP in Ubuntu: Step-by-Step How To! « Shafiul Azam's Weblog 
 
Howto setup Database Server With postgresql and pgadmin3 | Ubuntu Geek
Step-by-step Installation Guide for Ubuntu - MoodleDocs

Howto setup Database Server With postgresql and pgadmin3 | Ubuntu Geek

Install PostgreSQL on Ubuntu 8.04 - hocuspokus

Using PostgreSQL on Debian and Ubuntu

如何在 Ubuntu 下安裝 PostgreSQL 9.0 和 pgAdmin III 1.12.0 | IT 與攝影 ─ 黑喵的家

2012年1月5日 星期四

POP3 / IMAP Server


dovecot

courier

cyrus

---------------------

procmail

---------------------

Squirrelmail (PHP)

Openwebmail (Perl)




Reference :
Ubuntu Server 安裝 Postfix + pop3 imap @ 蒼芎技術筆記本 :: 痞客邦 PIXNET ::

2012年1月3日 星期二

Python Memcache

# apt-get install memcached python-memcached
// 若沒有 python-memcached 這個套件
// $ wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-latest.tar.gz
# vi /etc/memcached.conf
# /etc/init.d/memcached restart 
 

import memcache 
mc = memcache.Client(['127.0.0.1:11211'], debug=0)

mc.set("foo", "bar", 60*5)

value = mc.get("foo") 
print value

2012年1月1日 星期日

WDS (Wireless Distribution System)

Wireless Repeater


條件:
1. AP Module 具有 "WDS" 功能 (*儘量使用相同的 AP 機器)
2. 串連 AP 的 SSID、Channel、驗證加密方法要相同 (*據說 WPA 不行, 我 WEP 也還沒成功)
3. 兩個 AP 的 IP 要同網段
4. 只需要其中一台開啟 DHCP Server
5. 在 WDS 的設定中,將橋接的 AP MAC address 加入 (*即讓本機可以連上另台  AP, 用 "ping" 做 troubleshooting)




#!/bin/sh

ifconfig ath0 down
iwconfig ath0 channel 11
ifconfig ath0 up
ifconfig ath0 0.0.0.0

wlanconfig wdsath0 create wlandev wifi0 wlanmode wds
iwpriv wdsath0 wds_add 00:22:2d:01:94:df
iwpriv wdsath0 wds 1
ifconfig wdsath0 up

brctl addbr br1
brctl addif br1 ath0
brctl addif br1 wdsath0
ifconfig br1 192.168.44.254 up




======== 未測 ========
# /etc/network/interfaces


auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto ath0
iface ath0 inet manual
        madwifi-base wifi0
        madwifi-mode ap
        wireless-essid voyage-wds
        wireless-channel 1
        wireless-key aaaaaaaaaaaaaaaaaaaaaaaaaa
        up ifconfig ath0 up

auto ath1
iface ath1 inet manual
        madwifi-base wifi0
        madwifi-mode wds
        wireless-key aaaaaaaaaaaaaaaaaaaaaaaaaa
        up iwpriv ath1 wds_add 00:00:00:00:00:00
        up ifconfig ath1 up

auto br0
iface br0 inet static
        address 192.168.0.254
        netmask 255.255.255.0
        bridge_ports ath0 ath1 eth0
======== 未測 ========
 
 
 
 
Reference :
旗標知識網:WDS 無線中繼 - 擴大無線涵蓋範圍, 消弭連線死角 
㊣【網路】這裡有一批AP好便宜(WDS篇) @ ChampionHare's Update :: 痞客邦 PIXNET :: 
什麼是WDS (Wireless Distribution System) @ 麒靈的部落格 :: 隨意窩 Xuite日誌 

HAProxy Status

http://yoururl.com/haproxy?stats

DNAT (Virtual Server)

# modprobe iptable_nat

# echo "1" > /proc/sys/net/ipv4/ip_forward
 
# iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 9999 -j DNAT --to-destination 192.168.44.200:9999

DHCP IP 租用狀況

# less /var/lib/dhcp3/dhcpd.leases



[Python] DHCP3 leases parser - Pastebin.com

 27     m = re.match(r"\s+(starts)\s+\d+\s+(\d+\/\d+\/\d+)", line);
 28     if m:
 29         key, value = m.groups()
 30         if key == "starts":
 31             lease["time"] = value.lower()