Author Archives: admin

build openvpn from command line

first download the source and cd to the extracted directory, you should run follow commands:

wget http://swupdate.openvpn.org/community/releases/openvpn-2.3.4.tar.gz
tar -zxvpf openvpn-2.3.4.tar.gz
cd openvpn-2.3.4
aptitude install libssl-dev liblzo2-dev libpam0g-dev gcc make -y
./configure
make
make install

download with urllib and got exception: UnicodeEncodeError: ‘charmap’ codec can’t encode character

When you are download html with urllib or something alike, if you have this message:

File “C:\Python33\lib\encodings\cp437.py”, line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: ‘charmap’ codec can’t encode character

Chances are you are print() out some unsupported char most likely in utf-8 in the sys.stdout, but your sys.stdout console is default to cp437.
A fix is put a line like this before the print code as here:
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,'cp437','backslashreplace')

besides you can also use utf-8 as the encoder:
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,'utf-8')

auto mount a windows folder share on debian startup for development purpose

Auto mount a windows folder share on debian startup could be your honey if you run into this situation:
1. run linux as a website server development environment
2. most of your tools with good ui only run under windows
To bridge this gap, you want to have linux access to your windows share, and this is how to do it:
work on the windows:

  1. create a user “linuxweb” with the password “1y1cc1″ (please use your own values in your situation)
  2. share your work folder as “workproject” and make sure the user “linuxweb” you created have all the permission

work on the linux:

  1. create the mount point by these commands:
    mkdir /website
    mkdir /website/winworkproject
  2. setup auto mount on debian boot, run:
    pico /etc/rc.local
    and add this line to the file:
    mount -t cifs //192.168.1.99/workproject -o username=linuxweb,password=1y1cc1,uid=www-data,gid=www-data /website/winworkproject

One problem:
There is one problem I run into during this adventure: I initially tried to auto mount the share by fstab:
//192.168.1.99/workproject /website/winworkproject cifs username=linuxweb,password=1y1cc1,uid=www-data,gid=www-data 0 0
but got an error saying:
CIFS VFS: cifs_mount failed w/return code = -112
I have no clue what code -112 is, then I have to do it by rc.local and it looks work well. Please leave a comment below if you know what code -112 is, thanks!