xdebug的安装

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/install_xdebug/

xdebug是一个开源的php调试器,以php模块的形式加载并被使用。

windows 平台下:

一、安装xdebug模块
1、去www.xdebug.org下载相应版本php的模块文件,保存下载后的文件到php的ext目录,可以自己修改文件的名称,现在最新的版本是 2.0.1。
2、修改php.ini,增加如下信息

[Xdebug]
zend_extension_ts="d:/php/ext/xdebug-xxx.dll"
xdebug.auto_trace=on
xdebug.collect_params=on
xdebug.collect_return=on
xdebug.trace_output_dir="d:\Temp\xdebug"
xdebug.profiler_enable=on
xdebug.profiler_output_dir="d:\Temp\xdebug"

参数解释:
zend_extension_ts="d:/php/ext/xdebug-xxx.dll"
加载xdebug模块。这里不能用extension=xdebug-xxx.dll的方式加载,必须要以zend的方式加载,否则安装上后, phpinfo打印出来的里的xdebug段的会有XDEBUG NOT LOADED AS ZEND EXTENSION的警告信息。

xdebug.auto_trace=on
自动打开“监测函数调用过程”的功模。该功能可以在你指定的目录中将函数调用的监测信息以文件的形式输出。此配置项的默认值为off。

xdebug.collect_params=on
打开收集“函数参数”的功能。将函数调用的参数值列入函数过程调用的监测信息中。此配置项的默认值为off。

xdebug.collect_return=on
打开收集“函数返回值”的功能。将函数的返回值列入函数过程调用的监测信息中。此配置项的默认值为off。

xdebug.trace_output_dir="d:\Temp\xdebug"
设定函数调用监测信息的输出文件的路径。

xdebug.profiler_enable=on
打开效能监测器。

xdebug.profiler_output_dir="d:\Temp\xdebug"
设定效能监测信息输出文件的路径。

另外,xdebug 不能和 Zend Optimizer 以及其他 Zend 扩展 (DBG, APC, APD etc) 同时工作,目前这个问题正在修复中。

还有一些更为具体的参数设定,详见:http://www.xdebug.org/docs-settings.php

3、重启apache

这样,在本地运行php的时候,会在所设定的目录里产生一些调试信息的文件:

* 函数调用过程监测信息文件的文件名格式:trace.××××××.xt。这个文件可以直接查看,里面包含了函数运行的时间,函数调用的参数值,返回值,所在的文件和位置等信息。内容格式还是相对直观的。
* 效能监测文件的文件名格式:cachegrind.out.××××××××。
这个文件也可以直接查看,不过信息格式不易被人类所理解,
所以我们需要接下来的一个软件。

二、安装wincachegrind
由于效能监测文件:cachegrind.out.××××××××文件的内容不易被人类所理解,所以我们需要一个工具来读取它。windows下就有一款这样的软件:wincachegrind。
1、到http://sourceforge.net/projects/wincachegrind/下载安装wincachegrind
2、安装运行后,点击Tools->options,设定你的working folder(php.ini里xdebug.profiler_output_dir的值)
这样就可以比较直观的查看效能监测文件的信息了。

控制输出CacheGrind文件名的控制
http://xdebug.org/docs/all_settings#trace_output_name

ubuntu 下安装

一、安装xdebug
1. 先到xdebug.org下载最新的源码包。
2. 编译安装

tar -zxvf xdebug-xxx.tgz
cd xdebug-xxx
phpize
./configure --enable-xdebug
make
sudo make install

3. 修改配置文件php.ini,添加下面一行
zend_extension_ts="/wherever/you/put/it/xdebug.so"
这里的/wherever/you/put/it/是 xdebug.so 所在的目录
第一行将装入 Xdebug 扩展;第二行将启用 Xdebug 的分析器功能,而第三行将启用扩展的调试功能。

一些推荐的配置

xdebug.default_enable = On

xdebug.collect_params=on
xdebug.collect_return=on

xdebug.profiler_enable = On
xdebug.profiler_output_dir="E:\server\xdebug\profiler"

xdebug.auto_trace = 1
xdebug.trace_output_dir="E:\server\xdebug\trace"
xdebug.trace_format = 1
xdebug.trace_output_name = trace.%c

xdebug.show_exception_trace = On
xdebug.show_local_vars = 1
xdebug.max_nesting_level = 50
xdebug.var_display_max_depth = 6

xdebug.dump_once = On
xdebug.dump_globals = On
xdebug.dump_undefined = On
xdebug.dump.REQUEST = *
xdebug.dump.SERVER = REQUEST_METHOD, REQUEST_URI, HTTP_USER_AGENT

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9999

4. 重启apache,然后再phpinfo信息里就可以看到 Xdebug 的部分了。

二、安装 Debug client
1. 下载 Debug client
2. 解压缩源代码包,然后安装

cd debugclient
./configure --with-libedit
make
sudo make install

参考文章:
http://xdebug.org/docs/install
http://www.leeyupeng.com/?p=325
http://www.phpres.com/html/gaojiyingyong/20070921/1781.html

-- EOF --

Ubuntu 7.04 下 virtualbox 安装及桥接网络配置

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/virtualbox_install_and_network_config/

一、安装

1. 下载安装包。建议下载 Deb 包

2. 准备依赖。VirtualBox 的正常使用需要 libxalan110 和 libxerces27 这两个包。所以,你要先行安装它们,可以使用下面的指令:
sudo apt-get install libxalan110 libxerces27

3. 安装编译工具及相关包。在安装过程中,要编译 VirtualBox 所用的内核模块。为此,你需要准备基本的编译工具及包,你可以使用下列指令来安装它们:
sudo apt-get install build-essential linux-headers-`uname -r`

4. 现在,转到所保存 VirtualBox 安装包的目录,通过下面的指令来安装它:
sudo dpkg -i VirtualBox_1.x.x_Ubuntu_feisty_i386.deb
在安装的过程中,VirtualBox 会要求你接受许可协议。另外,安装程序也会创建 vboxusers 用户组,并编译所需的内核模块。
5. 现在,你还不能启动 VirtualBox,因为你的当前用户还不属于 vboxusers 用户组。你可以使用下面的指令来将当前的用户(请使用你的用户名代替指令中的“youruser”)添加到 vboxusers 用户组中:
sudo adduser youruser vboxusers

virtualbox 屏幕下移问题:
如果虚拟机的分辨率接近x的分辨率而导致部分界面在x边沿时,全屏后原来窗口管理器 title 的地方变为黑色条状区域,屏幕下移,windows的开始菜单显示在下一个桌面。
解决方法:全屏前把分辨率调小,全屏后右键把显示器分辨率调到同x一致,这样就不会有屏幕偏移。

二、桥接网络配置

一般而言,安装完VirtualBox设定网路时选择默认的NAT模式,Guest就可顺利联网了,但是这种方式比较死板,要作更有弹性的变化,应该采用桥接模式(Bridged),这里的桥接模式就如同VMware中的Bridged模式,Host与Guest在局域网(LAN)中的地位是相等的。

参考 virtualbox 安装后放在 VirtualBox 目录中的用户手册文件 UserManual.pdf 配置如下:

1. 在基于 Debian 和 Ubuntu 的系统上,首先要安装含有建立虚拟网络设备 ( TAP interfaces ) 的工具 uml-utilities 和桥接工具 bridge-utils:
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils

为了使你的虚拟机能够访问网络接口,你必须将运行虚拟主机的用户的用户名(通常是你的ubuntu登录用户名)添加到uml-net用户组(请用你的用户名替换其中的“vboxuser”):
sudo gpasswd -a vboxuser uml-net
注意:为了使改动生效,请重新启动你的电脑。

2. 向你的 Debian 或者 ubuntu 操作系统描述你要添加的虚拟网络设备,编辑 /etc/network/interfaces:
sudo vim /etc/network/interfaces
在打开的文件后面添加下面的内容,将虚拟网络接口命名为 "tap0",指定该接口IP配置方法为手动,并指定使用该接口的用户(请用你的用户名替换其中的 "vboxuser"):
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user vboxuser

3. 首次使用需要激活刚才建立的虚拟网络接口和网络桥:
sudo /sbin/ifup tap0
sudo /sbin/ifup br0

这个步骤只需要做一次,下次主机重新启动时,这个接口和桥将自动激活。

4. 另外还需要在 /etc/network/interfaces 中加入如下内容,建立一个名叫 "br0" 的桥,该桥的IP配置方法为通过DHCP配置,主机中的所有网络接口,也包括tap0这个虚拟网络接口,都将建立在这个桥之上:
auto br0
iface br0 inet dhcp
bridge_ports all tap0

在这里你可以根据自己的网络状况做相应的更改,你可以使网络桥使用静态 IP:
iface br0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

5. 让 virtualbox 使用这个虚拟网络接口,启动 virtualbox,在主界面上选中要使用刚才建立的虚拟网络接口tap0的虚拟机,点“设置”,在弹出的窗口中选“网络”,选中其中一块网卡(通常为“网络适配器 0”),选中“启用网络适配器”,“连接到”后面选 "Host Interface",选中“接入网线”,然后在“主机网络界面名称”中填入刚才建立的虚拟网络接口的名字 "tap0",确定。同样的你也可以使用 VBoxManage 的命令行工具(将 "My VM" 换成你的虚拟机名字 ):
VBoxManage modifyvm "My VM" -hostifdev1 tap0\

最后,配置主机和虚拟机的网络,使主机和虚拟机在同一个网段,这样主机和虚拟机就成了局域网中地位相同的两台机器了,可以互相访问了。

三、撤销网络桥
1. 禁用网桥和虚拟网卡:
sudo /sbin/ifdown br0
sudo /sbin/ifdown tap0

2. 将前面修改的 /etc/network/interfaces 文件还原。

Debian 和 Ubuntu 下 virtualbox 桥接设置原文:

6.5.1.1 Debian and Ubuntu hosts

To set up a permanent host interface on a Debian or Ubuntu host, follow these steps:

1. On modern Debian and Ubuntu based hosts, you must first install the UserMode Linux utilities package (uml-utilities), which contains tools to create TAP interfaces, as well as the bridge utilities (bridge-utils). package. You can do this from the command line using

sudo apt-get install uml-utilities
sudo apt-get install bridge-utils

In order for VirtualBox to be able to access the interface, the user who will be running the virtual machine must be added to the group uml-net, for example with the following command (replace vboxuser with your user name):

sudo gpasswd -a vboxuser uml-net

You may have to log out and log in again for the change to take effect.

2. To describe the TAP interface to your Debian or Ubuntu system, add an entry to the file /etc/network/interfaces. This names the the interface and must also specify the user who will be running the virtual machine using the interface. The following sample entry creates the interface tap0 for the user vboxuser (again, replace with your user name):

auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user vboxuser

You will probably want to change the entry based on your networking needs. On the host, you will find more documentation in these files:
a) /usr/share/doc/uml-utilities/README.Debian and
b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.

3. The first time it is used, activate the new interface and the bridge with these two commands:

sudo /sbin/ifup tap0
sudo /sbin/ifup br0

This is only needed once, however; the next time the host is restarted, the interface and the bridge should be activated automatically.

4. Another entry must be added to the file /etc/network/interfaces to describe the bridge. The following sample entry creates a bridge called br0, adds to it all ethernet interfaces on the host as well as the TAP interface created above and tells it to obtain an IP address using DHCP so that the host remains able to access the network.

auto br0
iface br0 inet dhcp
bridge_ports all tap0

Again, you will probably want to change this to suit your own networking needs. In particular, you may want to assign a static IP address to the bridge, or if you are using TAP interfaces created by VirtualBox (these are described later), you
will want to remove tap0 from the last line. On the host, you will find more documentation in the files

a) /usr/share/doc/bridge-utilities/README.Debian.gz and
b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.

5. To tell VirtualBox to use the interface, select the virtual machine which is to use it in the main window of the VirtualBox application, configure one of its network adaptors to use Host Interface Networking (using "Settings", "Network",
“Attached to”) and enter “tap0” into the “Interface name” field. Alternatively, you can use the VBoxManage command line tool (in this example we are attaching the interface to the first network card of the virtual machine ("My VM"):

VBoxManage modifyvm "My VM" -hostifdev1 tap0

-- EOF --

再谈自定义 ubuntu 安装

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/diy_your_ubuntu/

之前发过这篇文章,不过基本上都是转抄别人的,而且有点纸上谈兵,之后经过多次在虚拟机及实际的安装过程中又发现许多问题,现在再发一篇,算是自己的安装记录吧。

1、安装基本系统

这里安装使用的是Ubuntu 7.04 的 Alternate CD。使用 Alternate CD 引导启动,然后选择 “安装命令行系统(Install Command Line)” 进行最小化安装,在这一步,要注意,一定不要选择中文语言环境,否则在终端窗口下的各种提示,有很多都是中文的。在没有装载完成X Window之前,你只能看到一堆杂乱的小方块。另外安装过程中可以做一下网络设置。

系统分区
Linux 下最少得有 2 个分区,一个是 /swap 交换分区,一个是 / 根分区。
一般桌面用户推荐选用 ReiserFS 文件系统,分区方案如下 (80G):

/swap 512M
/ 8G
/home 70G

swap 分区不建议超过 1G,不低于 128M。

2、网络配置

在基本系统安装完成后,会要求重新启动一次系统,使用在安装过程中设置的帐号及密码登录。
使用ADSL上网的,这里先设置ADSL:
sudo pppoeconf
pon dsl-provider #上线
poff #下线

非拨号用户使用以下命令设置网络
sudo vim /etc/network/interfaces

网卡通过DHCP自动获取IP地址
# The primary network interface (配置主网络接口)
#开机自动激活eth0接口
auto eth0
#配置eth0接口为DHCP自动获取
iface eth0 inet dhcp

获取IP地址
sudo dhclient eth0

网卡静态分配IP地址
#开机自动激活eth0接口
auto eth0
#配置eth0接口为静态设置IP地址
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

激活以上设置
sudo /etc/init.d/networking restart

DNS 设置
sudo /etc/resolv.conf
加入
nameserver 202.102.152.3

3、修改、更新源

sudo vim /etc/apt/sources.list
系统安装之后默认的是亚洲官方的源,建议网通修改为台湾大学的源,电信修改为 CN99 的源,具体可以参考这里。然后更新源(我的sources.list):
sudo apt-get update
sudo apt-get dist-upgrade

更新的时候要注意更新的完整性

4、安装基本图形系统及窗口管理器

sudo apt-get install x-window-system-core gdm build-essential
x-window-system-core是x-window的核心组件;gdm是Gnome的登录界面,同类的有KDE的登录界面kdm和另一个轻量级的xdm;build-essential是编译程序源码所必须的组件。

窗口管理器使用 fluxbox ,由自己来编译,编译fluxbox时需要以下组件
sudo apt-get install xorg-dev xserver-xorg-dev checkinstall xlibs-dev
到 Fluxbox 主页下载最新的源码包,解压,在终端中cd进解压目录,然后进行编译(我下的是v1.0rc3):
tar zxvf fluxbox-1.0rc3.tar.gz
cd fluxbox-1.0rc3
./configure
make
sudo make install

安装完之后,设置GDM,即可以在GDM界面选择从Fluxbox还是Gnome等别的环境启动。

对于没有安装任何桌面环境的用户可以在自己主目录下创建.xsession 文件,或者创建.xinitrc 文件,填入下列内容:
exec startfluxbox
对于需要在多个环境下切换的用户可以在 /usr/share/xsessions/ 下创建 fluxbox.desktop 文件,fluxbox 的具体设置见这里,这里附上我的 apps , keys , menu 文件以及我的 fluxbox 主题

5、安装显卡驱动

去 nvidia 官方下载驱动
Nvidia显卡驱动安装的时候要对内核作改动,这里需要一个组件:
sudo apt-get linux-headers-`uname -r`
注意上面的单引号是Esc键下那个,不是Enter键左边那个。
以后在图形界面下如果要修改屏幕刷新率或者分辨率可以在终端或运行对话框中输入
nvidia-settings
安装可以参考这里

相关命令
gdm 的启动与关闭
sudo /etc/init.d/gdm stop
sudo /etc/init.d/gdm restart

6、安装简体中文语言包与输入法

sudo apt-get install language-pack-zh language-pack-gnome-zh
系统的简体中文语言包。

sudo apt-get install fcitx
输入法,另外还有一个是 SCIM。
这里还需要一个输入法管理器
sudo apt-get install im-switch
安装完之后要激活输入法
sudo im-switch -s fcitx
系统字体刷新
sudo fc-cache -f -v

7、调整更改时区,时间

如果同时又装了 windows 的话,由于 windows 并不启用UTC (GMT),会导致时间不对,这时候要执行:
tzselect
按照提示进行选择时区,然后:
sudo cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime
执行
sudo ntpdate cn.pool.ntp.org
cn.pool.ntp.org是位于中国的公共NTP服务器,用来同步你的时间。

8、安装相关工具及软件

sudo apt-get install gksudo
安装好之后在 fluxbox 的菜单menu中加入 {gksudo 命令},就会直接在X下提示 su 的密码。

sudo apt-get install synaptic
Gnome的新立得软件包管理器,就是图形界面的源管理器。

sudo apt-get install feh fbpager
feh: 一个图片查看工具,Fluxbox中使用fbsetbg设定壁纸之后fbsetbg会自动寻找一个可以设置壁纸的程序,feh就是其中的一个。
fbpager: Fluxbox的虚拟桌面扩展工具。
设置壁纸:
fbsetbg -f /home/lost/.wp.jpg

sudo apt-get install gnome-session gtk2-engines*
gnome-session: 比gnome-core更简洁,目的是为了在fluxbox启动的时候加载gnome-settings-daemon,从而使GTk界面的程序的外观不那么丑。
gtk2-engines*: gtk的外观主题引擎,加载了gnome-settings-daemon才会使之生效。
以上两项装完之后应该就已经装上了Gnome的设置中心:gnome-control-center,它包括了指向所有Gnome环境变量修改工具的链接。

sudo apt-get install gnome-alsamixer
gtk的图形界面音量调整工具。安装之后默认情况下音量是静音的,打开音量调整工具,将静音的复选框中的箭头去掉即可。

sudo apt-get install rox-filer file-roller
rox-filer: 文件管理器。
file-roller: 各种压缩包的图形前端。

sudo apt-get install sun-java6-jdk
java开发环境,附带有java运行环境。

sudo apt-get install conky
在桌面显示当前系统状态,如果安装后出现出现闪烁,解决办法如下:

安装wmctrl:
sudo apt-get install wmctrl
修改xorg.conf文件:
sudo vim /etc/X11/xorg.conf
在Module段加入一行:
Load "dbe"
保存后退出。

设置conky的配置文件(我的.conkyrc配置文件):
vim ~/.conkyrc
设置以下几项:
own_window yes
own_window_type override
double_buffer yes

保存后退出。
重新启动系统就好了。

9、安装高级应用程序

sudo apt-get install vim-full vim-python scite openoffice.org openoffice.org-gtk openoffice.org-l10n-zh-cn evince xpdf xpdf-chinese-simplified xpdf-chinese-traditional gimp wine
vim-full vim-python 是Vim的完整组件。
scite 是轻量级的编辑器,简体中文语言文件 locale.properties 放到 scite 安装目录下,一般为 /usr/share/scite,再附上我的用户配置文件 SciTEUser.properties
openoffice.org 大名鼎鼎的 openoffice,openoffice.org-gtk 可以使Ooo和Gnome主题保持一致,openoffice.org-l10n-zh-cn 是 openoffice 的简体中文语言包。
evince是PDF文档查看工具,xpdf xpdf-chinese-simplified xpdf-chinese-traditional三个组件用于解决部分中文PDF文档出现乱码的问题。
gimp 类似于Photoshop的东西,现在PS没有Linux版本。
wine 安装Windows程序必备。

sudo apt-get install amule filezilla firefox mozilla-firefox-locale-zh-cn thunderbird tsclient mplayer mozilla-mplayer vlc vlc-plugin-esd mozilla-plugin-vlc
amule 是Linux下的电骡。
filezilla 是FTP工具。
mozilla-firefox-locale-zh-cn 是 firefox 的简体中文包。
thunderbird 是和 Firefox 同出一源的电子邮件工具,不过我用它来阅读新闻组和RSS新闻,它是Linux下对中文新闻组支持最好的工具。
tsclient 是linux下的远程桌面工具。
mplayer Linux最强大的多媒体播放器,由于知识产权的原因,7.04的源中没有再提供其解码器w32codecs的下载,可以到其官网上下载 all-20061022.tar.bz2 和 windows-all-20061022.zip 两个包,解压后前者mv到 /usr/lib/codecs,后者mv到/usr/lib/win32目录中即可,这两个目录如果没有就建立它。
mozilla-mplayer firefox的mplayer插件,使FF支持播放网页中的内嵌媒体。
VLC 多媒体播放器,不过不支持 real 格式。

另外有一些软件,源上没有或者源上的版本较老或不好用的:
Opera:最好的网络浏览器,可到其官方网站下载。
Pidgin:原来叫Gaim,可到 getdeb 下载deb包,包括 pidgin 和 pidgin-data 。安装:
sudo dpkg -i package
Skype:不用说了吧。
MultiGet 图形界面的下载工具,现在更新换代了,开发代号为 monma这里下载。
Tux Commander 类似 Total Commander 的工具。

10. 结束
至此,自己定制的操作系统已经完成了,当然还可根据自己的需要继续安装其它软件。

-- EOF --

ububtu 7.04 下的 nvidia 显卡驱动安装

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/install_nvidia_driver_above_ubuntu/

1. 到http://www.nvidia.com/ 下载适合的驱动
97xx 和 96xx 的驱动相关支持参见这里

2. 删除原来的驱动(如果你装过驱动)
sudo apt-get --purge remove nvidia-glx

3. 备份当前的显示设置,这样可以在驱动安装失败时恢复到原来的设置
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

4. 安装驱动程序编译环境
sudo apt-get install build-essential linux-headers-`uname -r`

5. 禁止系统使用默认的驱动
sudo vim /etc/default/linux-restricted-modules-common
在最后的双引号中添加nv,即 "" 改成 "nv"

6. 按Ctrl+Alt+F1,登录,停止gdm或kdm
sudo /etc/init.d/gdm(kdm) stop

7. 进入下载的驱动安装文件 nvidia-linux-x86-1.0-****-pkg1.run所在目录(请确定xorg-dev软件包已经安装,编译过程中可能会用到)
sudo sh nvidia-linux-x86-****.run
如果提示缺少某某模块(modules),询问是否上网下载,选no;

8. 安装完成后,启动gdm
sudo /etc/init.d/gdm start
此时,就会看到NVIDIA的LOGO了,驱动安装成功。

9. 删除 nVidia标志
* 如果您不想在启动界面之前显示 nVidia 标志,您需要手动编辑您的 Xorg 配置文件.
sudo vim /etc/X11/xorg.conf
在Device一节中找到 "nvidia" 所在行,在该行后添加
Option "NoLogo"
保存文件并退出,重启X

其中第5步非常重要,我就是因为它用了接近一下午时间。

-- EOF --