2009年9月13日星期日

How to setup Netbeans 6.7 PHP debug environment in Ubuntu 8.04

1. Enable personal HTTP directory

1.1 use sudo command to create two symbolic links in /etc/apache2/mod-enabled directory:
sudo ln -s ../mods-available/userdir.conf userdir.conf
sudo ln -s ../mods-available/userdir.load userdir.load

1.2 create HTTP directory in the user's home directory:
makedir public_html

1.3 restart apache web server
sudo /etc/init.d/apache2 restart

1.4 test personal HTTP directory
use web browser to browse http://localhost/~[username]/

2. Enable xdebug

2.1 install xdebug DEB package

2.2 add the following lines in /etc/php5/apache2/php.ini:
zend_extension=xdebug.so
xdebug.remote_enable=on

3. Setup Netbeans PHP project

3.1 enable "copy files from sources folder to another location" and set the folder to user HTTP directory

3.2 in "run Configuration" page, set "Project URL" to user HTTP directory

2009年9月12日星期六

/etc/network/if-up.d 目錄下的 shell script

當 Ubuntu 啟動所有網絡介面時 (/etc/init.d/network 呼叫 ifup -a), 如果網絡介面成功啟動,那麼 /etc/network/if-up.d/ 目錄下的 shell script 會被執行. 例如有個 shell script 是這樣的:

#!/bin/sh

if [ $IFACE != "lo" ]; then
/sbin/route add default gw 192.168.1.254 $IFACE
fi

那麼只要網路介面不是 lo, route 就會執行, 即將 192.168.1.254 設為該介面的 gateway.
更多資料可以在 interfaces 的 man page 找到: man interfaces.