Archive for the ‘BSD+Linux’ Category

Linux 好棒.. ?

Monday, October 1st, 2007

Ubuntu 真的很棒,只要妳用的東西是很熱門很多人研究過,Google 打下去就會出現很詳細 Howto 的話,那的確很棒。但是如果要用的東西不很熱門,或者是某些公司出的 linux 板程式,那很容易要裝個東西就會浪費掉一兩個小時。

剛為了要裝 Oboe Sync 3.0,被 Python、Qt3 vs Qt4、PyQt、sip 這些錯縱複雜的關係搞得很機。抓下來一個 .tar.gz 也沒說要啥 dependency 然後就只有一個 oboe_exe.py,跑了後才開始靠背少了什麼東西。

去找 PyQT 然後又跟我說要編需要 sipconfig,鬼才知道那東西是在哪個 package 裡面。繞了一大圈發現 sip 是 PyQT 同一間公司出的,靠北是不會說喔。

好不容易要開始編 sip 然後又開始靠北說三小

Error: Failed to create ./qtdirs using platform linux-g++.
Make sure your compiler is installed correctly and you have a working make on your PATH. "

最好是這種 error message 有意義。

Google 又找了一下發現是寫 configure.py 的人很白爛,qt3 和 qt4 共存的時候只會抓到 qt3 然後就爆了。又仔細的爬了一下文發現可以用 -q 選項來指定 qmake 的 absolute path,所以來找一下 qmake 在哪裡:

peter@50k:~$ which qmake
/usr/bin/qmake
peter@50k:~$ ls -al /usr/bin/qmake
lrwxrwxrwx 1 root root 23 2007-09-25 22:38 /usr/bin/qmake -> /etc/alternatives/qmake
peter@50k:~$ ls -al /etc/alternatives/qmake
lrwxrwxrwx 1 root root 18 2007-10-01 18:24 /etc/alternatives/qmake -> /usr/bin/qmake-qt3
peter@50k:~$ ls -al /usr/bin/qmake-qt3
-rwxr-xr-x 1 root root 2032164 2007-09-18 10:05 /usr/bin/qmake-qt3
peter@50k:~$ ls /usr/share/qt4/*/qmake
/usr/share/qt4/bin/qmake
peter@50k:~$ whereis qmake-qt4
qmake-qt4: /usr/bin/qmake-qt4 /usr/X11R6/bin/qmake-qt4 /usr/bin/X11/qmake-qt4 /usr/share/man/man1/qmake-qt4.1.gz

靠北夠不夠麻煩阿,Linux 想要更普及話的話,這些問題都得排除。能夠想像你媽打電話來問說要怎麼裝啥啥啥程式嗎?對啦妳可以直接 ssh 進去,那如果變成一個客服要做的時候,最好是有辦法每個 client 都給他 ssh 進去修。

沒有 .deb 的東西還是少裝,省得在那邊覺得為啥只是簡單的想要裝個程式,卻浪費了一堆冤枉時間,到頭來只是幾行沒有人跟你說的指令而已。更!

Ubuntu 7.10 條教筆記

Saturday, September 29th, 2007

nVidia TwinView

  1. 在 Restricted Drive Manager 停用 nVidia 的 Driver
  2. 去 nVidia 官方網站抓最新的 Linux Driver 讓他裝
  3. 在 Restricted Drive Manager 啟用 nVidia 的 Driver
  4. 用 nVidia X Server Setting 來設定 TwinView

Screenshot-NVIDIA X Server Settings

FASTTRAK 378 RAID 0

  1. 安裝 dmraid: sudo apt-get install dmraid
  2. 建立 mount point: sudo mkdir /media/raid0
  3. 測試: sudo mount /dev/mapper/pdc_cbchadihee1 /media/raid0
  4. 最後再把這個 mount point 寫入 /etc/fstab 讓下次重開時候自動 mount

GCIN

  1. 在 Synaptic 裡面把 SCIM uninstall 掉然後安裝 GCIN
  2. 在 shell 裡面輸入 im-switch -s gcin
  3. 把 ~/.gtkrc.mine 改成:

    export GTK_IM_MODULE=gcin
    export LC_CTYPE=”zh_TW.UTF-8″

  4. 登出再登入

Sound

  1. 打開 System / Preferences / Sound
  2. 把 Sound playback 選成 VIA 8237

Desktop Effect

  1. sudo apt-get install ccsm
  2. System / Advanced Desktop Effects Settings

Screenshot-CompizConfig Settings Manager

Fonts

  1. 安裝微軟正黑體:

    sudo cp msjh* /usr/share/fonts
    sudo chmod o+rx /usr/share/fonts/msjh*
    sudo fc-cache -f -v

  2. 打開 Firefox: Edit / Preferences 然後把所有字體預設都改成 Microsoft JhengHei 省得麻煩

sshfs

sudo apt-get install sshfs
adduser peter fuse

GDM Dead Keyboard
這個奇怪的問題似乎有人碰過: Keyboard not funtioning at login。問題應該是像上面那篇文章寫的一樣,不知道為什麼 gdm 會比其他的 getty 開啟的更早,導致 keyboard 的控制被 getty 拿去,然後 gdm 下啥都不能做了囧。我用比較簡單的解法:

  1. 把 gdm 預設關閉:mv /etc/rc2.d/S30gdm /etc/rc2.d/K70gdm
  2. 在 /etc/rc.local 加入:service gdm start

Wine + Wine Doors

  1. Wine:

    wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
    sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/feisty.list -O /etc/apt/sources.list.d/winehq.list
    sudo apt-get update
    sudp apt-get install wine

  2. Wine Doors: 去這裡下載最新的 deb 然後讓 Package Manager 自動安裝

Microsoft IntelliMouse Explorer

  1. 修改 /etc/X11/xorg.conf:

    Section “InputDevice”
    Identifier “Mouse0″
    Driver “mouse”
    Option “CorePointer”
    Option “Device” “/dev/psaux”
    Option “Protocol” “ExplorerPS/2″
    Option “Buttons” “7″Option ”
    ButtonMapping” “1 2 3 4 5″
    Option “ZAxisMapping” “6 7″
    Option “Resolution” “100″
    EndSection

  2. 安裝 imwheel: sudo apt-get install imwheel
  3. 修改 /etc/X11/imwheel/imwheelrc:

    “.*” None,Up,Alt_L|Left None,Down,Alt_L|Right”^firefox-bin$”
    None,Left,Alt_L|Left
    None,Right,Alt_L|Right

  4. 新增 /etc/X11/Xsession.d/57xmodmap:
    #/bin/bash
    xmodmap -e “pointer = 1 2 3 6 7 4 5″

  5. 把 /etc/X11/Xsession.d/57xmodmap 改成執行檔: sudo chmod 755 /etc/X11/Xsession.d/57xmodmapservice

aMSN + gcin 中文輸入問題

Wednesday, September 26th, 2007

剛把 Ubuntu 預設的 SCIM 換成 gcin 後發現 aMSN 不能打中文

初步的找了一下猜測可能是 GTK+ 的 IM Module 沒有設定好

在 ~/.gtkrc.mine裡面加了一行

export GTK_IM_MODULE=gcin

重開 x 候很神奇的就可以輸入了

後來又找了一下,是我沒有設 Locale 的問題?

系統內跟語言有關係的設定是這樣

declare -x LANG=”en_US.UTF-8″
declare -x LANGUAGE=”en_US:en”

歐反正現在可以用,而且比 SCIM 好用多了 XD

PHP 5.2.1 on FC4 x86_64 compile note

Saturday, April 21st, 2007

Linking libraries from its default location

ln -s /usr/include /opt/include
ln -s /usr/lib64 /opt/lib

Now configuring with new location:

./configure --prefix=/usr/local --enable-force-cgi-redirect --enable-fastcgi --with-libxml --with-zlib --with-bz2 --with-curl  --with-gd --enable-mbstring --with-mysql --with-jpeg-dir=/opt --with-png-dir=/opt --with-mysql=/opt

Use Shared Host’s MySQL on VPS

Sunday, April 15th, 2007

On my 1&1 VPS II server, it comes with only 256MB of dedicated memory, which is pathetic. If I run a separate mysqld, it’s going to take 1xxMB away from this super limit memory pool. It makes sense to me to make use of MySQL databases on another shared hosting account. BlueHost and HostMonster both comes with firewall enabled by default for their MySQL servers. Going about white listing server’s IP can be done via:

  1. Launching remote firefox session, which takes your patient and the hassle of all those x window configs.
  2. Setup VPN on the server, and use server’s IP to to whitelist itself.

But the connection between the VPS server and Shared Host’s MySQL database is insecure. It’s natural to come to this conclusion as the best option: ssh tunnel.

Assuming you have shell access to both VPS and Shared Host, and both are running OpsnSSH.

Setup Public Key Authentication

  1. Login to VPS with account you want to create the tunnel
  2. cd ~/.ssh

    (create it if not exist)

  3. ssh-keygen -t dsa
  4. Securely transfer id_dsa.pub to the Shared Hosting’s home directly, something like this:
    scp id_dsa.pub sharedhost:/home/username/.ssh/server_id_psa.pub
  5. Login to Shared Host
  6. cd ~/.ssh
    cat server_id_psa.pub >> authorized_keys
  7. Switch back to VPS, try logging into Shared Host using public key authentication:
    ssh username@sharedhost

    If everything is setup properly, no password is prompted.

If in doubt, [this] is a good place to consult about Public Key Authentication.

Setting up a host name

When MySQL is connecting to localhost, it will try to use socket, regardless of the efforts trying to tell it the service is actually not running on localhost, but rather a tunnel to a remote host. To overcome this issue, create an entry in /etc/hosts:

127.0.0.1 localhost mysqlhost

This points the host name ‘mysqlhost’ to 127.0.0.1 which essentially is also localhost, but mysql is too dumb to understand.

Create the tunnel

  1. First, stop the local mysqld. As root:

    service stop mysqld
  2. Login to VPS with username previously configured with public key authentication to Shared Host
  3. create tunnel:
    ssh -f username@sharedhost -N -L 3306:localhost:3306

    This creates a ssh tunnel in background and forward connection to port 3306 on localhost to port 3306 on sharedhost.

  4. Make change in php to reflect the database names, users, password on Shared Host, and most importantly, instead of localhost, use mysqlhost in configuration files.

Automate the process

What if the ssh tunnel died? What if the VPS restarts? How to make sure the connection stays live? The answer is to use autossh.

  1. As root:

    yum install autossh
  2. Edit /etc/rc.d/rc.local, add this line at the bottom:
    su VPSusername -c 'autossh -M 5307 -f SHAREDHOSTusername@sharedhost -N -L 3306:*:3306' &

    This tells the server to execute the command in ‘ ‘ as VPSusername and put the process into background at startup. autossh will use port 5307 to monitor the ssh tunnel to sharedhost, and reconnect if it drops. Also make sure to disable the local MySQL daemon from starting automatically, or the tunnel cannot be created.

All Rights Reserved Copyright © 2008 Design by StyleShout and Clazh