FreeBSD 分类中的最新日记

# cd /usr/ports/graphics/pear-Image_Barcode && make install clean

<?php
require_once('Image/Barcode.php');
Image_Barcode::draw('RR651943036CN', 'Code39', 'gif');
exit;
?>

安装 GeoIP

| 暂无评论 | 暂无引用通告
FreeBSD 7.0-RELEASE-i386 + PHP5 + Apache2.2
# cd /usr/ports/net/pecl-geoip && make install clean
# apachectl restart
# cd ~
# fetch http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
# gunzip GeoIP.dat.gz
# mv GeoIP.dat /usr/local/share/GeoIP/GeoIP.dat
# fetch http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# gunzip GeoLiteCity.dat.gz
# mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat

<?php
echo geoip_database_info(GEOIP_COUNTRY_EDITION);

$country = geoip_record_by_name('wangblog.org');
if($country){
	echo "\nThis host is located in: \n";
	print_r($country);
}
?>

可以写个定时更新IP地址库的程序:
cd ~
/usr/bin/fetch http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
/usr/bin/gunzip GeoIP.dat.gz
mv GeoIP.dat /usr/local/share/GeoIP/GeoIP.dat
/usr/bin/fetch http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
/usr/bin/gunzip GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat

以上保存为:update-ipdata-cron.sh

crontab -e
添加以下一行,每月5日0点10分运行:
10 0 5 * * /bin/csh /path/to/update-ipdata-cron.sh
FreeBSD 8.0-RELEASE-i386 + IBM ThinkPad X32 Intel(R) PRO/Wireless 2200bg

除了 /etc/rc.conf 其他的和7.0一样,8.0要将无线网卡clone出来wlan再使用。妈的,搞了一个晚上才搞好!一直以为是Fn+F5出错无法启动无线网卡。


下面的添加入 /etc/rc.conf ,无线网卡即可正常使用:
ifconfig_iwi0="up"
wlans_iwi0="wlan0"
ifconfig_wlan0="ssid TP-LINK_57850C wepmode on weptxkey 1 wepkey 1:0x1234567890 DHCP"
其余的参考 FreeBSD7.0无线网卡设置
FreeBSD 8.0-RELEASE-i386 + IBM ThinkPad X32

下列,添加到 /etc/rc.conf:
hald_enable="YES"
dbus_enable="YES"

PORT安装Xorg,KDE是很慢的,所以用CD来装,没有光驱怎么办?虚拟光驱吧,先下载 8.0-RELEASE-i386-dvd1.iso 到WinXP的分区中,然后虚拟。

# mkdir /mnt/fat32
# mount_msdosfs /dev/ad0s6 /mnt/fat32

fat32、ntfs、cd9660分区中文文件名的问题。以前中文目录有gbfs port支持,现在无需安装gbfs即可实现fat32分区中文文件名的显示。方法是在执行mount_msdosfs时加载-L zh_CN.eucCN的参数,如:
mount_msdosfs -L zh_CN.eucCN /dev/ad0s1 /mnt/disk

对于ntfs及cd9660格式,则用另一个参数-C gbk,如:
mount_cd9660 -C gbk /dev/acd0 /cdrom
mount_ntfs -C gbk /dev/ad0s1 /mnt/win

FreeBSD里的逻辑分区是从ad0s5开始的,因为支持4个主分区,即使只有一个主分区,也是从ad0s5开始的。

# mkdir /mnt/cdrom
# mdconfig -a -t vnode -f /mnt/fat32/8.0-RELEASE-i386-dvd1.iso -u 1
# mount_cd9660 /dev/md1 /mnt/cdrom

# sysinstall

Configuration->packages->选择7 File System(/mnt/cdrom)->进入x11->找xorg->选中->install
Configuration->packages->选择7 File System(/mnt/cdrom)->进入KDE->找kde->选中->install

配置Xorg:
# Xorg -configure
# Xorg -config xorg.conf.new
# cp xorg.conf.new /etc/X11/xorg.conf

# cd /usr/ports/chinese/kcfonts && make install clean
# cd /usr/ports/chinese/arphicttf && make install clean
# cd /usr/ports/chinese/kde4-l10n-zh_CN && make install clean

# cd /usr/ports/www/firefox3 && make install clean
# cd /usr/ports/www/firefox3-i18n && make install clean

# cd /usr/ports/chinese/scim-pinyin/ && make install clean
# ee ~/.cshrc
setenv LANG zh_CN.eucCN
setenv LC_CTYPE zh_CN.eucCN
setenv XMODIFIERS @im=SCIM
setenv GTK_IM_MODULE scim
# echo "exec /usr/local/bin/scim &" >> ~/.xinitrc
# echo "exec /usr/local/kde4/bin/startkde" >> ~/.xinitrc
# startx

这样 FreeBSD8.0 KDE4 中文桌面就安装完毕了。可以和 FreeBSD 7.0 参考,基本差不多。

昨天 freebsd8.0 releases 正式发布,新版本增加了 8.0-RELEASE-i386-memstick.img 文件,在8.0-RC 的版本中就有了。整个安装过程中遇到了一些问题,与大家一起分享。

1、IBM ThinkPad X32 安装FreeBSD的问题

IBM ThinkPad X32 笔记本确实好用,但也有变态的地方。比如 BIOS 的设置基本没用,要通过操作系统来修改属性。这几天一直在 IBM ThinkPad X32 笔记本上装 FreeBSD 但是一直失败,安装程序在预装时,检测到硬盘就死机:

md0:preloaded image 4423680 bytes at 0xc0d7f830
ad0:152627MB at ata0-master UDM100
基本就在死在上面的位置,解决方法:
在Windows XP下安装ThinkPad Configuration
ThinkVantage->ThinkPad Configuration->Device Bay 设置为Disable
是扩展坞的问题,关闭扩展坞居然在BIOS里找不到设置的项目?所谓人无完人,机无完机!


2、Writing FreeBSD memstick.img to a USB drive in Windows

去下载dd for windows

dd for windows

  1. E:\>dd --list
  2. rawwrite dd for windows version 0.5.
  3. Written by John Newbigin <jn@it.swin.edu.au>
  4. This program is covered by the GPL. See copying.txt for details
  5. Win32 Available Volume Information
  6. \\.\Volume{ab8f5a50-d757-11de-8c1b-806d6172696f}\
  7. link to \\?\Device\HarddiskVolume1
  8. fixed media
  9. Mounted on \\.\c:
  10.  
  11. \\.\Volume{ab8f5a51-d757-11de-8c1b-806d6172696f}\
  12. link to \\?\Device\HarddiskVolume3
  13. fixed media
  14. Mounted on \\.\d:
  15.  
  16. \\.\Volume{ab8f5a52-d757-11de-8c1b-806d6172696f}\
  17. link to \\?\Device\HarddiskVolume4
  18. fixed media
  19. Mounted on \\.\e:
  20.  
  21. \\.\Volume{64acdc22-d831-11de-8c23-08002700405e}\
  22. link to \\?\Device\Harddisk1\DP(1)0-0+10
  23. removeable media
  24. Mounted on \\.\f:
  25.  
  26.  
  27. NT Block Device Objects
  28. \\?\Device\Harddisk0\Partition0
  29. link to \\?\Device\Harddisk0\DR0
  30. Fixed hard disk media. Block size = 512
  31. size is 40007761920 bytes
  32. \\?\Device\Harddisk0\Partition1
  33. link to \\?\Device\HarddiskVolume1
  34. \\?\Device\Harddisk0\Partition2
  35. link to \\?\Device\HarddiskVolume2
  36. Fixed hard disk media. Block size = 512
  37. size is 10001940480 bytes
  38. \\?\Device\Harddisk0\Partition3
  39. link to \\?\Device\HarddiskVolume3
  40. \\?\Device\Harddisk0\Partition4
  41. link to \\?\Device\HarddiskVolume4
  42. \\?\Device\Harddisk1\Partition0
  43. link to \\?\Device\Harddisk1\DR15
  44. Removable media other than floppy. Block size = 512
  45. size is 1999633920 bytes
  46. \\?\Device\Harddisk1\Partition1
  47. link to \\?\Device\Harddisk1\DP(1)0-0+10
  48. Removable media other than floppy. Block size = 512
  49. size is 1999601664 bytes
  50.  
  51. Virtual input devices
  52. /dev/zero (null data)
  53. /dev/random (pseudo-random data)
  54. - (standard input)
  55.  
  56. Virtual output devices
  57. - (standard output)
  58.  
  59. E:\>dd if=8.0-RELEASE-i386-memstick.img of=\\?\Device\Harddisk1\Partition0 bs=10240 --progress
  60. rawwrite dd for windows version 0.5.
  61. Written by John Newbigin <jn@it.swin.edu.au>
  62. This program is covered by the GPL. See copying.txt for details
  63. 923,207,680
  64. 90157+0 records in
  65. 90157+0 records out
  66.  
  67. E:\>dd --help
  68. rawwrite dd for windows version 0.5.
  69. Written by John Newbigin <jn@it.swin.edu.au>
  70. This program is covered by the GPL. See copying.txt for details
  71. dd [bs=SIZE] [count=BLOCKS] [if=FILE] [of=FILE] [seek=BLOCKS] [skip=BLOCKS] [--s
  72. ize] [--list] [--progress]
  73. SIZE and BLOCKS may have one of the following suffix:
  74. k = 1024
  75. M = 1048576
  76. G = 1073741824
  77. default block size (bs) is 512 bytes
  78. skip specifies the starting offset of the input file (if)
  79. seek specifies the starting offset of the output file (of)
  80.  
  81. E:\>

View this snippet on OpenTags.org

Linux直接:

wget ftp://ftp.freebsdchina.org/pub/FreeBSD/ISO-IMAGES-i386/8.0/8.0-RC1-i386-memstick.img
dd if=8.0-RC1-i386-memstick.img of=/dev/da0 bs=10240 conv=sync

dd if=8.0-RELEASE-i386-memstick.img of=\\?\Device\Harddisk1\Partition0 bs=10240 --progress
要根据你的实际情况更改,if=8.0-RELEASE-i386-memstick.img of=\\?\Device\Harddisk1\Partition0 bs=10240 别反了,反了就是把U盘的内容保存为镜像文件。

3、用U盘启动安装FreeBSD8.0

主板要支持USB-HDD启动,不然就没戏。启动过程比较长,2~3分钟的样子,然后就进入sysinstall,不多说,基本和FreeBSD7.0安装差不多,就是 Media 选择安装媒介时选USB,U盘启动安装FreeBSD8.0可能还不成熟,我第二次时居然没有找到USB设备。

4、选择了 Standand 从FreeBSD启动,无法 MBR 启动 WinXP怎么办

当时情况特殊,因为不小心在BIOS里 LOAD DEFAULT SETUP 打开了扩展坞,真变态,BIOS里禁用不了却可以打开。所以,WInXP 和 FreeBSD 都进不去了。只好用 Win98启动盘启动进入纯DOS(注意是纯DOS),用A:\>fdisk /mbr,然后重启,移除FreeBSD Boot Manager,如果提示找不到操作系统,还是用A:\>fdisk 进去设置启动分区。具体查询DOS的fdisk命令。

可以进WinXP了,关闭扩展坞,然后用U盘启动进入sysinstall,Configuration -> FDisk 选择你想boot的分区,按'S'激活,然后按'W'存盘,sysinstall会问你安装哪个bootmanager,选择Bootmgr 就可以了,然后Exit Installation,Reboot,就可以了。

5、如何恢复U盘

用 UltraISO 9.0 以上的版本,硬盘写入或者格式化就可以恢复U盘。不多说了,简单的问题。

6、FreeBSD8.0 比 7 要大很多,要注意安装空间的配置

好了,基本的安装就结束了,明天再试试KDE怎么样,有什么变化!

Mr Wang

王炜,现在福建泉州从事 B2C 电子商务。爱好编程,业余时间在 FreeBSD / Apache / PHP / PostgerSQL 平台开发 B/S 架构的免费软件。

订阅Feed 订阅 王炜's Blog

Follow Google Buzz Twitter Facebook LinkedIn Sina

收藏王炜's Blog

关于此归档

这里是分类FreeBSD中的最新日记。

上一个分类FreeBAPP

下一个分类Internet

首页归档页可以看到最新的日记和所有日记。