<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?632</link>
<title><![CDATA[centos FreeBSD 查看CPU核数使用率 系统 位 内存大小 硬盘 HBA光纤卡号 常用命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Fri, 08 Apr 2016 04:08:11 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?632</guid> 
<description>
<![CDATA[ 
	一：使用CentOS常用命令查看cpu<br/><br/>more /proc/cpuinfo &#124; grep "model name" &nbsp; <br/>grep "model name" /proc/cpuinfo &nbsp; <br/>[root@localhost /]# grep "CPU" /proc/cpuinfo &nbsp; <br/>model name &nbsp; &nbsp; &nbsp;: Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz &nbsp; <br/>model name &nbsp; &nbsp; &nbsp;: Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz &nbsp; <br/>如果觉得需要看的更加舒服<br/>grep "model name" /proc/cpuinfo &#124; cut -f2 -d:<br/><br/> <br/><br/> <br/><br/>查看linux系统是多少位<br/><br/> &nbsp; &nbsp;使用命令如下：<br/><br/> &nbsp; &nbsp;uname -a<br/>如果结果类似于这样：<br/>[root@localhost ~]# uname -a<br/>Linux localhost.localdomain 2.6.18-92.el5xen #1 SMP Tue Apr 29 13:45:57 EDT 2008 i686 i686 i386 GNU/Linux<br/>表明是32位<br/>如果显示结果是x86_64，表明是64位<br/><br/> <br/><br/> <br/><br/>二：使用CentOS常用命令查看内存<br/><br/>grep MemTotal /proc/meminfo &nbsp;grep MemTotal /proc/meminfo &#124; cut -f2 -d: &nbsp;free -m &#124;grep "Mem" &#124; awk '{print $2}'<br/><br/>三：使用CentOS常用命令查看cpu是32位还是64位<br/><br/>查看CPU位数(32 or 64)<br/>getconf LONG_BIT<br/><br/>四：使用CentOS常用命令查看当前linux的版本<br/><br/>more /etc/redhat-release<br/>cat /etc/redhat-release<br/><br/>五：使用CentOS常用命令查看内核版本<br/><br/>uname -r<br/>uname -a<br/><br/>六：使用CentOS常用命令查看当前时间<br/><br/>date上面已经介绍如何同步时间了<br/><br/>七：使用CentOS常用命令查看硬盘和分区<br/><br/>df -h<br/>fdisk -l<br/>也可以查看分区<br/>du -sh<br/>可以看到全部占用的空间<br/>du /etc -sh<br/>可以看到这个目录的大小<br/><br/>八：使用CentOS常用命令查看安装的软件包<br/><br/>查看系统安装的时候装的软件包<br/>cat -n /root/install.log<br/>more /root/install.log &#124; wc -l<br/>查看现在已经安装了那些软件包<br/>rpm -qa<br/>rpm -qa &#124; wc -l<br/>yum list installed &#124; wc -l<br/>不过很奇怪，我通过rpm，和yum这两种方式查询的安装软件包，数量并不一样。没有找到原因。<br/><br/>九：使用CentOS常用命令查看键盘布局<br/><br/>cat /etc/sysconfig/keyboard<br/>cat /etc/sysconfig/keyboard &#124; grep KEYTABLE &#124; cut -f2 -d=<br/><br/>十：使用CentOS常用命令查看selinux情况<br/><br/>sestatus<br/>sestatus &#124; cut -f2 -d:<br/>cat /etc/sysconfig/selinux<br/><br/>十一：使用CentOS常用命令查看ip，mac地址<br/><br/>在ifcfg-eth0 文件里你可以看到mac，网关等信息。 &nbsp;ifconfig &nbsp;cat /etc/sysconfig/network-scripts/ifcfg-eth0 &#124; grep IPADDR &nbsp;cat /etc/sysconfig/network-scripts/ifcfg-eth0 &#124; grep IPADDR &#124; cut -f2 -d= &nbsp;ifconfig eth0 &#124;grep "inet addr:" &#124;awk '{print $2}'&#124;cut -c 6- &nbsp;ifconfig &nbsp; &#124; grep 'inet addr:'&#124; grep -v '127.0.0.1' &#124; cut -d: -f2 &#124; awk '{ print $1}' &nbsp;查看网关 &nbsp;cat /etc/sysconfig/network &nbsp;查看dns &nbsp;cat /etc/resolv.conf &nbsp;十二：使用CentOS常用命令查看默认语言<br/>echo $LANG $LANGUAGE<br/>cat /etc/sysconfig/i18n<br/><br/>十二：使用CentOS常用命令查看所属时区和是否使用UTC时间<br/><br/>cat /etc/sysconfig/clock<br/><br/>十三：使用CentOS常用命令查看主机名<br/><br/>hostname<br/>cat /etc/sysconfig/network<br/>修改主机名就是修改这个文件，同时最好也把host文件也修改。<br/><br/>十四：使用CentOS常用命令查看开机运行时间<br/><br/>uptime<br/>09:44:45 up 67 days, 23:32, ...<br/>看来刚才确实是网段的问题，我的机器还是67天前开机的。<br/>#系统资源使用情况<br/><br/>2. 注销系统 请在 # 号后，输入 logout 或 exit 表示离开。 当你完成注销，系统会显示出 login 的画面。<br/><br/>1、freebsd下如何查看程序所占用的端口？<br/><br/>#sockstat<br/><br/>#netstat -na<br/><br/> <br/><br/>2 、route相关命令<br/><br/>查询 routing table<br/>#netstat -rn<br/><br/> <br/><br/>查询网络接口流量统计<br/>#netstat -I<br/><br/> <br/><br/>查询 TCP网络联机情形<br/>#netstat -t<br/><br/> <br/><br/>查询所有网络联机情形<br/>#netstat -a<br/><br/> <br/><br/>netstat 查看端口状态，如：<br/>#netstat -an &#124; grep tcp &nbsp; 查看开放的tcp端口<br/><br/> <br/><br/>3、如何查看系统所有进程/用户进程<br/><br/>#ps -A<br/><br/>#ps auxww （查看系统所有进程）<br/><br/>#ps或ps -ef 查看用户进程<br/><br/> <br/><br/>4、FreeBSD下怎么查看内存大小<br/><br/>#top （可以查看，但不直观）<br/><br/>#dmesg -a &#124; grep memory （这个很直内存大小)<br/><br/> <br/><br/>5、查看网络流量<br/><br/>#systat -if 1 (1表示1s刷新屏幕一次)<br/><br/>#netstat 1<br/><br/>#Traffic 表示当前流量 &nbsp;#peak表示流量峰值<br/><br/> <br/><br/>6、查看硬盘信息<br/><br/>#diskinfo -vt /dev/ad0 (整个硬盘信息)<br/><br/>#disklabel /dev/ad0 &nbsp;(分区信息）<br/><br/>#disklabel /dev/ad0s1 <br/><br/> <br/><br/>7、查看硬盘详细分区及读写状况<br/><br/> &nbsp;#gstat<br/><br/> <br/><br/>8、freebsd如何挂载光驱<br/><br/>1)普通挂载<br/><br/>#mount -t cd9660 &nbsp;/dev/acd0 /mnt<br/><br/>或 #mount_cd9660 -e /dev/cd0 /cdrom<br/><br/>2)挂载显示中文<br/><br/>#mount_cd9660 -C GB2312 &nbsp;-e &nbsp;/dev/cd0 &nbsp;/cdrom <br/><br/> <br/><br/>9、freebsd如何挂载USB、移动硬盘<br/><br/>1）普通挂载<br/><br/>#mount -t msdosfs /dev/da0s1 /data <br/><br/>或#mount_msdosfs /dev/da0s1 /data &nbsp;(注:挂载usb移动硬盘至/data目录) <br/><br/> <br/><br/>2）如何显示中文<br/><br/> #mount_msdos -L zh_CN.GB2312 -D cp936 /dev/ad0s1 /data<br/><br/> <br/><br/>3)访问NTFS<br/><br/>mount_ntfs -C eucCN /dev/ad0s5 /media/winD<br/><br/> <br/><br/> <br/><br/>10、Freebsd 下如何查看CPU个数<br/><br/>方法1：dmesg&#124;grep cpu<br/><br/>方法2:sysctl -a&#124;grep cpu<br/><br/> <br/><br/>11、Freebsd下如果CPU是多核，如何查看各颗CPU的运行状态:<br/><br/>方法1：top命令(在输出中，有一列的名字叫C,在STATE列后面，如下图:)<br/><br/>PID USERNAME &nbsp; &nbsp; THR PRI NICE &nbsp; SIZE &nbsp; &nbsp;RES STATE &nbsp;C &nbsp; TIME &nbsp; WCPU COMMAND<br/>35871 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;48 &nbsp; &nbsp;0 &nbsp;4520K &nbsp;2864K CPU1 &nbsp; 1 &nbsp; 0:00 &nbsp;0.49% top<br/>35867 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;20 &nbsp; &nbsp;0 &nbsp;4504K &nbsp;2312K pause &nbsp;2 &nbsp; 0:00 &nbsp;0.10% csh<br/> 1186 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4312K select 3 &nbsp; 0:57 &nbsp;0.00% httpd<br/>29884 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;9320K &nbsp;5232K select 1 &nbsp; 0:47 &nbsp;0.00% snmpd<br/>12482 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;8428K &nbsp;2792K select 3 &nbsp; 0:05 &nbsp;0.00% sshd<br/> &nbsp;768 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5876K &nbsp;2456K select 0 &nbsp; 0:01 &nbsp;0.00% sendmail<br/>34691 www &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4372K select 2 &nbsp; 0:01 &nbsp;0.00% httpd<br/>34748 www &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; 4 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4376K accept 0 &nbsp; 0:01 &nbsp;0.00% httpd<br/><br/>从上面的结果，可以知道，这是一颗四核的CPU<br/><br/> <br/><br/>AIX:<br/> &nbsp; &nbsp;1,获得AIX主机连接的光纤设备:<br/> &nbsp; &nbsp; &nbsp; # lsdev -Cc adapter -S a &#124; grep fcs<br/> &nbsp; &nbsp; &nbsp; &nbsp;fcs0 &nbsp; &nbsp; &nbsp;Available 09-08 FC Adapter<br/> &nbsp; &nbsp; &nbsp; &nbsp;fcs1 &nbsp; &nbsp; &nbsp;Available 09-09 FC Adapter<br/> &nbsp; &nbsp;其中,显示有两块光纤卡.fcs0和fcs1<br/> &nbsp; &nbsp;2,查看光纤卡的WWN号<br/> &nbsp; &nbsp; &nbsp; # lscfg -vpl fcs0<br/> &nbsp;fcs0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; U787B.001.DNWG664-P1-C1-T1 &nbsp;FC Adapter<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;Part Number.................10N8620<br/> &nbsp; &nbsp; &nbsp; &nbsp;Serial Number...............1B74404468<br/> &nbsp; &nbsp; &nbsp; &nbsp;Manufacturer................001B<br/> &nbsp; &nbsp; &nbsp; &nbsp;EC Level....................A<br/> &nbsp; &nbsp; &nbsp; &nbsp;Customer Card ID Number.....5759<br/> &nbsp; &nbsp; &nbsp; &nbsp;FRU Number.................. 10N8620<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZM)........3<br/> &nbsp; &nbsp; &nbsp; &nbsp;Network Address.............10000000C96E2898<br/> &nbsp; &nbsp; &nbsp; &nbsp;ROS Level and ID............02C82138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z0)........1036406D<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z1)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z2)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z3)........03000909<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z4)........FFC01159<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z5)........02C82138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z6)........06C12138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z7)........07C12138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z8)........20000000C96E2898<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z9)........BS2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZA)........B1F2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZB)........B2F2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZC)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Hardware Location Code......U787B.001.DNWG664-P1-C1-T1<br/> &nbsp; &nbsp;其中标红的部分就是光纤卡的WWN号<br/> &nbsp; &nbsp;<br/><br/>HP-Unix:<br/> &nbsp; &nbsp;1,列出HP机上连接的光纤卡设备:<br/> &nbsp; &nbsp; &nbsp; &nbsp;# ioscan -fnC fc<br/>Class &nbsp; &nbsp; I &nbsp;H/W Path &nbsp;Driver S/W State &nbsp; H/W Type &nbsp; &nbsp; Description<br/>=================================================================<br/>fc &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp;0/3/1/0 &nbsp; fcd &nbsp;CLAIMED &nbsp; &nbsp; INTERFACE &nbsp; &nbsp;HP A6826-60001 2Gb Dual Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/dev/fcd0<br/>fc &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp;0/3/1/1 &nbsp; fcd &nbsp;CLAIMED &nbsp; &nbsp; INTERFACE &nbsp; &nbsp;HP A6826-60001 2Gb Dual Port PCI/PCI-X Fibre Channel Adapter (FC Port 2)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/dev/fcd1<br/> &nbsp; &nbsp;由此图可以看到,/dev/fcd0和/dev/fcd1是两个光纤卡<br/> &nbsp; &nbsp;2, 查看光纤卡的WWN号<br/> &nbsp; &nbsp; &nbsp; # fcmsutil /dev/fcd0<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vendor ID is = 0x001077<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Device ID is = 0x002312<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PCI Sub-system Vendor ID is = 0x00103c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PCI Sub-system ID is = 0x0012ba<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PCI Mode = PCI-X 133 MHz<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ISP Code version = 3.3.18<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ISP Chip version = 3<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Topology = PTTOPT_FABRIC<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Link Speed = 2Gb<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Local N_Port_id is = 0xa10500<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Previous N_Port_id is = None<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N_Port Node World Wide Name = 0x50060b00001db241<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N_Port Port World Wide Name = 0x50060b00001db240<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Switch Port World Wide Name = 0x205e000dec0e2e00<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Switch Node World Wide Name = 0x2001000dec0e2e01<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Driver state = ONLINE<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hardware Path is = 0/3/1/0<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Maximum Frame Size = 2048<br/> &nbsp; &nbsp; &nbsp; &nbsp; Driver-Firmware Dump Available = NO<br/> &nbsp; &nbsp; &nbsp; &nbsp; Driver-Firmware Dump Timestamp = N/A<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Driver Version = @(#) libfcd.a HP Fibre Channel ISP 23xx & 24xx Driver B.11.23.04 /ux/core/isu/FCD/kern/src/common/wsio/fcd_init.c:Oct 18 2005,08:21:11<br/> &nbsp; &nbsp;其中红色部分显示了HBA卡的WWNN和WWPN号,另外还能看到该HBA卡连接的光纤交换机端口的WWN号<br/><br/><br/>Solaris:<br/> &nbsp; &nbsp;solaris上用luxadm命令来管理存储设备以及光纤相关设备.<br/> &nbsp; &nbsp;1, 查询现有存储设备和光纤设备,可以读到包括磁盘设备的WWN号<br/> &nbsp; &nbsp; &nbsp; &nbsp;# luxadm probe<br/> &nbsp; &nbsp;2, 查看HBA的prot,可以得到HBA卡的port值以及连接属性:<br/> &nbsp; &nbsp; &nbsp; # luxadm -e port<br/> &nbsp; &nbsp; &nbsp; &nbsp;/devices/pci@0,0/pci1022,7450@2/pci1077,101@1/fp@0,0:devctl &nbsp; &nbsp; &nbsp; &nbsp;NOT CONNECTED<br/> &nbsp; &nbsp; &nbsp; &nbsp;/devices/pci@0,0/pci1022,7450@2/pci1077,101@1,1/fp@0,0:devctl &nbsp; &nbsp; &nbsp;CONNECTED<br/> &nbsp; &nbsp;从中可以看到仅有一块光纤卡连接到存储设备<br/> &nbsp; &nbsp;3, 选择那个已经连接的HBA卡,查看其WWN号<br/> &nbsp; &nbsp; &nbsp; 格式: # luxadm -e dump_map 设备port.其中port值可从步骤2得到.如下图啊所示:<br/> &nbsp; &nbsp; &nbsp; # luxadm -e dump_map /devices/pci@0,0/pci1022,7450@2/pci1077,101@1/fp@0,0:devctl<br/>Pos &nbsp;Port_ID Hard_Addr Port WWN &nbsp; &nbsp; &nbsp; &nbsp; Node WWN &nbsp; &nbsp; &nbsp; &nbsp; Type<br/>0 &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp;210000e08b19827a 200000e08b19827a 0x1f (Unknown Type,Host Bus Adapter)<br/><br/><br/>Redhat:<br/> &nbsp; &nbsp;在Redhat中,设备管理的相关信息都保存在内核中,即/proc目录.所以我们一般查询CPU,内存,磁盘等信息,也是在该目录下. 其中HBA卡相关信息保存在/proc/scsi/qla2300/目录下,不同设备对应不同的文件名,例如<br/> &nbsp; &nbsp;# grep scsi /proc/scsi/qla2300/1<br/> &nbsp; &nbsp;Number of reqs in pending_q= 0, retry_q= 0, done_q= 0, scsi_retry_q= 0<br/> &nbsp; &nbsp;scsi-qla0-adapter-node=200000e08b9cf661;<br/> &nbsp; &nbsp;scsi-qla0-adapter-port=210000e08b9cf661;<br/> &nbsp; &nbsp;就可以查到系统第一块HBA卡的WWNN和WWPN号.<br/>Tags - <a href="tag.php?tag=cpu" rel="tag">cpu</a> , <a href="tag.php?tag=%E5%86%85%E5%AD%98" rel="tag">内存</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?631</link>
<title><![CDATA[FreeBSD常用的110条命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Sat, 31 Jan 2015 02:30:01 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?631</guid> 
<description>
<![CDATA[ 
	01.查看网络流量<br/> a.systat -if 1 （1表示1s刷新屏幕一次）<br/> b.netstat 1<br/> # Traffic 流量 peak 峰值 average 平均值<br/> 02.查看硬盘信息<br/> diskinfo -vt /dev/ad0<br/> disklable /dev/ad0 (分区信息)<br/> disklable /dev/ad0s2<br/> 03.查看核心信息<br/> vmstat 1<br/> 04.查看进程<br/> top ps auxww &nbsp; ps -ef &#124;grep xxx<br/> 05.查看硬盘详细分区信息＆读写状况<br/> gstat<br/> 06.sysctl sysctl -a 查看所有变量（/etc/sysctl.conf）<br/> sysctl kern.maxproc 查看特定变量<br/> sysctl kern.maxfiles=5000 设置变量<br/> 07.查看磁盘空间使用情形 df 和 du<br/> 指令df用来查看整个档案系统的使用情形，<br/> 如果您需要知道某个目录的使用情形用指令du。<br/> df -h<br/> du -h /etc<br/> du -sh /etc<br/> -s 参数来省略指定目录下的子目录<br/> -h 表示使用GB、MB等易读的格式<br/> 08.断电后系统无法启动<br/> a.启动到sing user模式<br/> b.fsck<br/> c.reboot<br/> 09.升级内核后无法启动<br/> a.重启机器到10秒读秒时按enter以外的任意键(新版bsd按6)<br/> b.unload<br/> c.boot kernel.old 或其他可以启动的内核<br/> 另外一种方法<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/boot<br/> d.rm -rf kernel<br/> e.cp -R kernel.old kernel<br/> f.reboot<br/> 修改了/boot/loader.conf以后不能正常引导系统了，当机器开始加载<br/> /boot/defaults/loader.conf的时候(未加载完)机器停止响应，我应该怎么办？<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/boot<br/> d.vi loader.conf 去掉错误的加载项<br/> e.reboot<br/> 10.丢失root密码<br/> 启动到单用户模式,执行/sbin/mount -a, 然后用passwd更改密码<br/> /sbin/mount -a=挂接/etc/fstab里所有列出的文件系统<br/> 如果单用户登录也需要密码<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/etc<br/> d.vi /ttys 找到when going to single-user mode,更改<br/> console none unknow off insecure为secure<br/> e.reboot,启动到单用户模式/sbin/mount -a,passwd<br/> 启动到单用户模式后，ctrl+d进入多用户模式<br/> ####让单用户登录也需要密码<br/> a.cd /etc<br/> b.vi /ttys 找到when going to single-user mode,更改<br/> console none unknow off secure为insecure<br/> 11.用win2000的引导器启动FreeBSD<br/> 我在笔记本上装了双系统，win2000 和freebsd，装完 freebsd后 系统自动设置如下：<br/> f1 dos<br/> f2 freebsd<br/> 先起动到dos下，fdisk /mbr，再把FreeBSD光盘上的boot&#92;boot1复制到c:&#92;,<br/> 再编辑c:&#92;boot.ini 加一行c:&#92;boot1="FreeBsd"<br/> 12.硬盘分区时shift+F -->NO可以使用全部空间<br/> 13.ctrl+alt+backspace 杀掉xwindows<br/> 14.alt+F1...F8 或 printscreensysr循环切换控制台<br/> 15.shutdown now 切换到单用户模式<br/> shutdown -p now shutdown -hp now 关闭电源<br/> shutdown -r now reboot 重新启动机器<br/> shutdown -p +90 (90分钟后关机)<br/> shutdown 0203122359(0203122359表示2002年3月12日23:59，格式是yymmddhhmm)<br/> 16.挂载ntfs,fat32分区和u盘<br/> ntfs: mount_ntfs -C eucCN /dev/ad0s5 /mnt/d<br/> fat32:mount_msdos -L zh_CN.eucCN /dev/ad0s6 /mnt/e<br/> u盘(scsi盘): &nbsp; mount_msdos -L zh_CN.eucCN /dev/da0s1 /mnt/u<br/> cdrom: #mount_cd9660 /dev/acd0 /mnt/cdrom<br/> NTFS在FreeBSD中只能只读而无法写入<br/> 17.卸载分区<br/> umount /dev/ad0s5<br/> umount -f /dev/ad0s5 (强制卸载)<br/> 18.在/etc/fstab中挂载fat32分区<br/> /dev/ad0s5 &nbsp; /mnt/d &nbsp; msdos &nbsp; rw,-L=zh_CN.eucCN 2 2<br/> 19.如何在FreeBSD5.X以上加载,卸载ISO文件<br/> mount iso文件：<br/> mdconfig -a -t vnode -f myisofile.iso (屏幕输出md0或者类似的设备名)<br/> mount -t cd9660 /dev/md0 /cdrom<br/> umount：<br/> umount /cdrom<br/> mdconfig -d -u 0 (上面的-u后面的数字和前面的md?中的数字一致)<br/> mdconfig -l 命令可以列出关于配置 md(4) 设备的信息<br/> 20.声卡<br/> vi /boot/defaults/loader.conf<br/> 更改snd_ich_load="NO"->"YES" #intel ich<br/> 检测声卡 kldstat 或 dmesg &#124;grep pcm<br/> 21.ls 命令详解<br/> ls 显示本目录下的文件及目录<br/> ls -a显示本目录下的所有文件及目录（包括隐藏目录和文件）<br/> ls -l 显示本目录下所有文件的属性<br/> ls -l &#124; grep ^d 只显示目录<br/> ls -l &#124; grep ^- 只显示文件<br/> ls -l &#124; grep ^d &#124; wc –l &nbsp; 统计当能目录下的子目录数<br/> ls -l &#124; grep ^- &#124; wc –l &nbsp; 统计当能目录下的文件数<br/> ls -G &nbsp; 以颜色显示目录名和文件名<br/> 22.查找程序或文件<br/> which 程序名<br/> whereis 程序名<br/> find 文件名<br/> locate 文件名<br/> locate: database too small: /var/db/locate.database的一种解决方法<br/> a.这个仅仅是因为你开机时间不够长，看看/etc/periodic/weekly/310.locate<br/> b.试试运行/usr/libexec/locate.updatedb看<br/> whatis xxx 要找东西但不知道它是什么<br/> grep bpf /usr/src/sys/i386/conf/GENERIC 在文件中找指定文本<br/> #只能对文本进行grep,如是命令,则<br/> command &#124;grep text<br/> grep text filename<br/> 23.xmms乱码问题 (要拷贝simsun.ttf和taboma.ttf到/usr/X11R6/lib/X11/fonts/TrueType/)<br/> 在用户目录下建立 .gtkrc.mine 文件.代码如下<br/> style "gtk-default-zh-cn" {<br/> fontset = "-*-tahoma-medium-r-normal-*-12-0-0-0-p-0-iso8859-1,<br/> -misc-simsun-medium-r-normal-*-*-120-*-*-p-*-gbk-0,*-r-*" }<br/> class "GtkWidget" style "gtk-default-zh-cn"<br/> 修改xmms中的字体设置，将播放清单及主窗口的字体修改为下面的设置<br/> -*-tahoma-medium-r-normal-*-12-0-0-0-p-0-iso8859-1,<br/> -misc-simsun-medium-r-normal-*-*-120-*-*-p-*-gbk-0,*-r-*<br/> xorg6.9+xfce4+xmms<br/> cd /usr/ports/chineses/xmms make install clean<br/> 拷贝simsun.ttf到/usr/X11R6/lib/X11/fonts/TTF/,无需要建立.gtkrc.mine<br/> 只要修改xmms中的字体设置,字体simsun,size 12就好了。<br/> 24.停止sendmail<br/> vi /etc/rc.conf 加入<br/> sendmail_enable="NONE"<br/> 25.you have mail<br/> mail 回车,输入1看第一封邮件...输入?看帮助<br/> mail 古老的 UNIX 邮件处理程序<br/> 如果我们要寄信给非本机的使用者，可以使用的收件人格式如下：<br/> mail -s"hi, my friend"<br/> jack@mymail.com<br/> mail -s "hi, my friend"<br/> jack@mymail.com<br/> zh_CN.eucCN<br/> 28.远程连接windows终端<br/> rdesktop [-a 16 -f] server'IP[:port]<br/> -a 16表示16位色,-f表示全屏<br/> gui，grdesktop (/usr/ports/net/grdesktop)<br/> 29.播放APE格式音乐<br/> /usr/ports/chinese/xmms/ /usr/ports/audio/xmms-mac(ape插件)xmms-wma(wma插件)<br/> 30.看图<br/> /usr/ports/graphics/xnview<br/> 31.apache22+php5+mysql+postgresql+ZendOptimizer<br/> a,apache22:<br/> cd /usr/ports/www/apache22<br/> make install clean<br/> b,php5:<br/> cd /usr/ports/lang/php5<br/> make install clean<br/> 选中APACHE，就可以联编出用于与Apache web服务器配合使用的可动态加载的mod_php5模块.<br/> 勿选debug,否则不能装ZendOptimizer<br/> c,php5扩展:<br/> cd /usr/ports/lang/php5-extesions<br/> make install [FORCE_PKG_REGISTER=yes] 强迫安装<br/> make clean<br/> (除预设项目还应选中CTYPE,EXIF,GD,ICONV,IMAP,PCRE,SESSION,ZLIB)<br/> FreeBSD中的PHP支持是高度模块化的，因此基本安装的功能十分有限。增加其他功能非常简单，只需通过lang/php5-extensions即可完成。这个port提供了一个菜单驱动的界面来帮助完成PHP扩展的安装。另外也可以通过对应的port来单独安装扩展。例如要将对于MySQL数据库服务器的支持加入PHP5，只需简单地安装databases/php5-mysql.<br/> d,cp /usr/local/etc/php.ini.recommended /usr/local/etc/php.ini<br/> e,ZendOptimizer<br/> cd /usr/ports/devel/ZendOptimizer<br/> make install clean<br/> f,mysql:<br/> cd /usr/ports/databases/mysql41-server<br/> make WITH_OPENSSL=yes BUILD_OPTIMIZED=yes WITH_CHARSET=gbk WITH_XCHARSET=all SKIP_DNS_CHECK=yes install<br/> ./work/mysql-5.0.24/scripts/mysql_install_db<br/> cd /usr/ports/databases/php5-mysql<br/> make install clean<br/> g,postgresql<br/> cd /usr/ports/databases/postgresql81-server<br/> make install clean<br/> /usr/local/etc/rc.d/postgresql initdb<br/> echo 'postgresql_enable="YES"' >> /etc/rc.conf<br/> cd /usr/ports/databases/php5-pgsql<br/> make install clean<br/> <br/>32.怎样刷新环境变量值，而不用退出再登陆？<br/> a,比如要重新设置环境变量ABC的值为abcdef<br/> bash$ export ABC=abcdef<br/> csh% setenv ABC abcdef<br/> b,更新了PATH变量指定目录里可执行命令<br/> rehash<br/> c,更新配置文件<br/> 比如你编辑了.cshrc等文件，就需要用source命令<br/> source .cshrc<br/> 33.检视软件间的关联<br/> cd /usr/ports/sysutils/pkg_tree<br/> make install clean<br/> 之后我们就可以使用 pkg_tree &#124; more 来看各个软件之间的关系了<br/> 34.使用 portupgrade 更新软件<br/> cd /usr/ports/sysutils/portupgrade<br/> make install clean<br/> 配置文件:/usr/local/etc/pkgtools.conf<br/> 如果您只想要升级某一个软件本身，而非所有相依的软件，只要使用portupgrade "pkgname" 即可。如果您要升级所有和该软件相依的其它软件，则可以加上参数 -r。如果您要更新包含相依软件的相依软件，则可以使用参数 -R。另外，您可以使用参数 -m 来要求编译 (make) ports 时多传入一些参数，还可以使用参数 -f 要求就算版本一样也强制更新。portupgrade在更新软件时，会保留您原本的设定档。例如，在更新 Apache 时，它会保留httpd.conf的设定。假设我们更新软件perl-5.8，我们可以用下列指令更新：<br/> # portupgrade -rRf "perl-5.8.*" -m "ENABLE_SUIDPERL=yes"<br/> 35.ports安装失败提示<br/> stop in /usr/ports/lang/ruby18/work<br/> 删除work目录下所有文件＆文件夹再次安装即可.(make clean)<br/> 36.ntop--网络监控软件<br/> cd /usr/ports/net/ntop<br/> make install clean<br/> vi /etc/rc.conf 加入<br/> ntop_enable="YES"<br/> 在地址栏中输入<br/> http://x.x.x.x:3000<br/> 即出来管理界面.<br/> 37.修改/etc/rc.conf不重启生效<br/> a.sh /etc/rc<br/> b./etc/netstart<br/> 38.freebsd启动的时候停到blanktime的解决办法<br/> 可以试试 这个参数:blanktime="NO"<br/> etc/rc.conf 中把 default_router 注释掉<br/> #未验证!!!<br/> 39.Bsd 下的QQ<br/> eva不错，运行速度飞快。<br/> /usr/ports/net-im/eva<br/> gaim-openq<br/> /usr/ports/net-im/gaim-openq<br/> 40.一次性把所有安装的ports删除掉<br/> a.pkg_delete -a<br/> 以下步骤去掉配置文件，解决一些疑难问题<br/> rm -fr /usr/local/<br/> rm -fr /var/db/ports/<br/> cd /usr/ports && make NOCLEANDEPENDS=yes clean<br/> portsnap fetch update<br/> b.安装pkg_cutleaves它会告诉你，哪些package没有人依赖，并让你决定要不要删除<br/> c.make deinstall与pkg_delete有什麽不同？<br/> 简单来说，make deinstall会移除该port，并且不会叁照其相依相关的ports。pkg_delete在移除该port前，会叁照其相依相关的ports，并且pkg_delete<br/> 有支援 wild card，如要移除所有p开头的 ports，则：<br/> cd /var/db/pkg/<br/> pkg_delete p*<br/> 要注意的是，如果使用 `make deinstall'，则最好确定系统目前所安装的版本，与 ports collection 中显示的版本符合，否则有可能会出现非预期性错误；而pkg_delete是因为直接删除系统中所安装的版本，所以没有此问题。<br/> 因此，换句话说，当系统所安装的版本符合ports collections中的版本，则可以使用make deinstall或pkg_delete，否则的话最好用pkg_delete。<br/> 41.pure-ftp安装<br/> cd /usr/ports/ftp/pure-ftpd/<br/> make WITH_LANG=simplified-chinese install clean<br/> [X] BANNER Show pure-ftpd welcome upon session start<br/> cd /usr/local/etc/<br/> cp pure-ftpd.conf.sample pure-ftpd.conf<br/> vi /etc/rc.conf -->加入pureftpd_enable="YES"<br/> 关于pureftpd的编码问题<br/> 在win下登陆ftp然后建立中文文件夹,传中文文件然后用FlashFXP登陆看到这些中文文件和文件夹名字全部是乱码.pure-ftpd.conf中强制用gbk就可以了.<br/> FileSystemCharset &nbsp; &nbsp;gbk<br/> ClientCharset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gbk<br/> 42.开机自动校准时间<br/> vi /etc/rc.conf--->加入<br/> ntpdate_enable="YES" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Run ntpdate to sync time on boot (or NO).<br/> ntpdate_flags="218.75.4.130" &nbsp; &nbsp; # cn.pool.ntp.org<br/> 43.将/usr/ports/distfiles/目录放到/data/disktfiles<br/> cd /usr/ports<br/> mv distfiles /data/distfiles [移动]<br/> ln -s /data/distfiles distfiles [链接][要在/usr/ports目录下做]<br/> ln -s source_file[_dir] target_file[_dir]<br/> 44.FreeBSD下面通过串口连接到路由器<br/> 使用cu -s speed -l line，就可以连接到COM口或者家猫的线路上，我用的是COM1口，<br/> 连接Cisco2924XL，使用cu -s 9600 -l ttyd0，即可连接上交换机配置界面。<br/> 45.电子书：CHM、PDF的查看<br/> chmsee,kchmviewer,xpdf,xchm,Acrobat Reader...chmsee对中文支持比较好<br/> /usr/ports/print/acroread7<br/> 46.使用axel或者prozilla加速你的port下载<br/> a.axel(据说能搞定文件夹钳套,不错!推荐使用 )<br/> cd /usr/ports/ftp/axel<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=axel -a<br/> DISABLE_SIZE=yes<br/> vi /usr/local/etc/axelrc 修改代码<br/> #num_connections = 4<br/> num_connections = 10<br/> 4改为10,num_connections前面不留空格,否则出错.<br/> (-a 交互的进步指示器,num_connections = 10 10线程下载)<br/> SIZE参数用来在取得文件之前检查文件的大小.而DISABLE_SIZE则是是否开启这项功能<br/> b.prozilla(速度快,遇到欠套的文件夹会出问题)<br/> cd /port/ftp/prozilla<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=proz -s -k=10 -r --no-curses<br/> DISABLE_SIZE=yes<br/> (-s 查找最快的境像,-k=10 10个线程下载,-r 重新开始一个被打断的下载)<br/> c.wget(未测试)<br/> cd /usr/ports/ftp/wget/<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=wget -c -t 1<br/> DISABLE_SIZE=yes #这行是必要的<br/> d.在其它机器上fetch<br/> make fetch-recursive (fetch:取得recursive:递归的)<br/> 然后将/usr/ports/distfiles拿走。<br/> ###make install设置是/etc/make.conf<br/> ###pkg_add是在~/.cshrc或~/.profile<br/> e.vi /etc/csh.cshrc<br/> 加上以下一行可以在让pkg_add先从更快的站点下载<br/> setenv PACKAGEROOT<br/> ftp://ftp.cn.freebsd.org<br/> 你可以先设定 PACKAGEROOT，这是用来抓取套件的位置,笔者通常设定<br/> setenv PACKAGEROOT<br/> ftp://ftp.tw.freebsd.org<br/> 因为这是我认为最稳定的机器，然后就可以透过pkg_add -r 套件名来安装套件，他会自动的到pub/FreeBSD/ports/i386/packages-4.9-release/Latest/底下寻找套件，而且你不需要知道版本，只要知道套件名称即可，他会自动安装当时的最新版，中文的部分只要加上 zh-，像是 zh-xcin。<br/> 你也可以直接指定 PACKAGESITE 来指向特定的位置。像是你希望安装的套件是最新的，而不是 release 时的版本。<br/> setenv PACKAGESITE<br/> ftp://ftp.tw.freebsd.org/pub/Fre<br/> ... ages-stable/Latest/<br/> f.vi /etc/make.conf<br/> 加上以下一行可以在让make先从更快的站点下载ports Distfiles<br/> MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/> ####http://ports.cn.freebsd.org/<br/> Welcome to use FreeBSD Ports Distfiles Mirror.<br/> This mirror is running on China Telecom 100Mbit network.<br/> How to use? Set your /etc/make.conf like this:<br/> MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/> or like this:<br/> MASTER_SITE_OVERRIDE?=http://ports.hshh.org/${DIST_SUBDIR}/<br/> 47.星际译王<br/> 辞典程序： /usr/ports/textproc/stardict2/<br/> 简体中文辞典：/usr/ports/chinese/stardict2-dict-zh_CN/<br/> 48.控制台调音量<br/> mixer<br/> 49.How to build openoffice<br/> cd /usr/ports/editors/openoffice.org-2.0<br/> Building/installing/packaging a localized language package (Japanese version for example)<br/> make LOCALIZED_LANG=ja install<br/> 去这里<br/> ftp://ooopackages.good-day.net/pub/OpenOffice.org/FreeBSD/<br/> 里面的tbz文件，<br/> 可以直接pkg_add<br/> 50.OPERA，支持Flash浏览器<br/> cd /usr/ports/www/linux-opera<br/> （注意是www/linux-opera，www/opera是不支持Flash的。）<br/> cd /usr/ports/www/opera<br/> make config<br/> 选中[X]SHARED Use a shared Qt library(instead of static)[解决在opera中输入汉字的问题]<br/> make install clean<br/> 安装后的美化:<br/> A.Tools->Preference->Advanced->Fonts，把所有的字体都改成Simsun，字体大小设成12。<br/> B.最小字体大小（像素）改为12.[解决一些网站看不清楚的问题]<br/> 51.bt客户端<br/> /usr/ports/net-p2p/py-bittorrent 安装完成后执行bittorrent<br/> /usr/ports/net-p2p/rtorrent 功能多，速度快，还完美支持中文编码！<br/> 52.emule客户端<br/> /usr/ports/net-p2p/amule2<br/> 53.ipguard解决arp攻击<br/> ipguard->Tool designed to protect LAN IP adress space by ARP spoofing<br/> /usr/ports/security/ipguard<br/> make install (不要clean参数,否则无ethers.sample文件)<br/> 补充：<br/> A.以/usr/ports/security/ipguard/work/ipguard-0.04/doc/ethers.sample<br/> 文件为实例，建立/etc/ethers文件。<br/> B.And then start ipguard:<br/> cd /usr/local/etc/rc.d<br/> mv ipguard.sh.sample ipguard.sh<br/> /usr/local/etc/rc.d/ipguard.sh start<br/> ipguard.sh启动脚本里默认有iface=fxp0，这里应该替换为你做NAT的内网网卡名称。<br/> 54.一些安装参数<br/> make fetch 只抓取tarball<br/> make fetch-recursive 抓取安装ports所有须要的其他ports的tarball<br/> make fetch-list 列出port所需的文件<br/> make clean Ports里面make clean,会附带着make clean依赖的软件的<br/> make -DBATCH install不需要用户输入任何东西<br/> make -DINTERACTIVE install 继续上一步<br/> make configure<br/> make distclean，删除不想要的distfiles<br/> 55.pkg_info<br/> pkg_info &#124;grep zh-fcitx (查软件版本)<br/> #ls /var/db/pkg也可以查软件版本<br/> pkg_info -L zh-fcitx-3.4 (查看软件安装目录和安装的文件)<br/> pkg_info -xL zh-fcitx (加x了不需要加软件版本号)<br/> pkg_info -r zh-fcitx-3.4 (查看软件依赖情况)<br/> pkg_info -W fcitx (查看fcitx属于哪个软件)<br/> 56.Ports如何清除安装参数<br/> cd /usr/ports/www/opera<br/> make distclean移除不是port collections所期望下载的文件<br/> make rmconfig清除用户配置的参数<br/> make showconfig查看当前配置的参数<br/> make config更改参数<br/> 57.一款好用的网络性能测试工具iperf<br/> /usr/ports/benchmarks/iperf<br/> 58.FreeBSD用户帐户锁定<br/> a.用vipw把他的shell修改成/sbin/nologin就可以了.<br/> b.pw lock useri 解锁用pw unlock userid 59.中文locale<br/> zh_CN.eucCN zh_CN.GBK zh_CN.GB18030 zh_CN.euc zh_CN.UTF-8<br/> #语言代码_国家代码.字符编码<br/> #查看环境变量：locale<br/> #目前还是zh_CN.eucCN(使用GB2312编码)locale最为正式，也最为成熟。<br/> 60.本地化设置,以系统默认的csh为例<br/> vi /etc/csh.cshrc 加入<br/> setenv LANG zh_CN.eucCN (语言设为中文)<br/> setenv LC_ALL zh_CN.eucCN (所有本地子集设为中文)<br/> setenv XMODIFIERS @im=fcitx (X下的中文输入法)<br/> set prompt = "%B%m"(个性化控制台%B颜色%m主机%/目录)<br/> set autolist &nbsp; (自动补齐扩展)<br/> set nobeep (告诉应用程式避免发出哔哔声)<br/> set filec &nbsp; &nbsp; (使档案名称在命令列被完成)<br/> alias ls &nbsp; &nbsp; &nbsp; &nbsp;ls -FG (彩色化ls)61.fcitx小企鹅输入法(有关步骤见60)<br/> /usr/ports/chineses/fcitx<br/> vi /root/.xinitrc 添加<br/> exec fcitx& 到最前一行<br/> 62.安装X Server xorg-6.9.0<br/> 1.cp freebsddisk1 disk2 PKG to /data/pkg61目录<br/> 2.cd /data/pkg61<br/> 3.pkg_add xorg-6.9.0.tbz<br/> 4.rehash<br/> 5.X[Xorg] -configure (生成/root/xorg.conf.new)<br/> 6.X[Xorg] -config /root/xorg.conf.new (测试xorg.conf.new配置是否正确)<br/> 7.cp /root/xorg.conf.new /etc/x11/xorg.conf<br/> 63.安装桌面环境gnome2 and xfce4 and kde3.5.1<br/> gnome2-2.12.3<br/> 1.cd /data/pkg61<br/> 2.pkg_add gnome2-2.12.3.tbz<br/> 3.rehash<br/> 4.vi /root/.xinitrc 加入 exec gnome-session<br/> #gnome2提示vi /etc/sysctl.conf,加入<br/> kern.ipc.shmmax=67108864<br/> kern.ipc.shmall=32768<br/> kern.maxfiles=25000<br/> xfce4<br/> 1.cd /usr/ports/x11-wm/xfce4<br/> 2.make install clean<br/> 3.rehash<br/> 4.vi /root/.xinitrc 加入 exec xfce4-session<br/> kde-3.5.1<br/> 1.cd /data/pkg61<br/> 2.pkg_add kde-3.5.1.tbz<br/> 3.rehash<br/> 4.cd /usr/ports/chineses/kde3-i18n-zh_CN<br/> 5.make install clean (kde3汉化)<br/> 6.vi /root/.xinitrc 加入 exec startkde<br/> pkg_add -r kde<br/> pkg_add -r zh_CN-kde-i18n<br/> pkg_add -r zh_CN-koffice-i18n<br/> ###more /root/.xinitrc<br/> exec fcitx&<br/> exec gnome-session<br/> #exec xfce4-session<br/> #exec startkde<br/> #exec /usr/X11R6/bin/gnome-session<br/> #exec /usr/local/bin/xfce4-session<br/> #exec /usr/local/bin/startkde<br/> 64.在Xwindow中使用TrueType字体(simsun宋体,msyh雅黑,tahoma)<br/> 1.cp simsun.ttc /usr/X11R6/lib/X11/fonts/TTF/simsun.ttf<br/> 2.cp msyh.ttf tahoma.ttf /usr/X11R6/lib/X11/fonts/TTF/<br/> 3.cd /usr/X11R6/lib/X11/fonts/TTF<br/> #下面4,5步骤更新字体信息,6重建字体缓存.<br/> 4.mkfontscale (生成fonts.scale)否则xorg报错如下:<br/> Could not init font path element/usr/X11R6/lib/X11/fonts/TTF/,removing from list!<br/> 5.mkfontdir (生成fonts.dir)否则xorg报错如下:<br/> (WW) `fonts.dir' not found (or not valid) in "/usr/X11R6/lib/X11/fonts/TTF/".<br/> Entry deleted from font path.<br/> (Run 'mkfontdir' on "/usr/X11R6/lib/X11/fonts/TTF/".<br/> 6.fc-cache -f -v (生成fonts.cache-1)<br/> 7.vi /etc/X11/xorg.conf 确认8<br/> 8.Load "freetype" (启用支持TrueType字体)<br/> #现在X应用程序已经记住已安装的TrueType字体.<br/> 9.在gnome和其他X程序中把字体设置为宋体或雅黑.<br/> 65.xlsfonts显示系统中安装的字体<br/> 66.FreeBSD中3D加速功能的启用<br/> a.DRI。<br/> 这是实现3D功能最重要的部分。DRI是Direct Rendering Infrastructure,可以简单的把它理解为X和硬件间的接口.但它包含很多独立的模块，负责从X到硬件的各个环节，包括内核。它最主要的工作就是将Mesa或OpenGL的函数调用转换为硬件的指令，从而指挥硬件进行渲染等工作。<br/> b.测试你的显卡是不是能实现3D功能，可以采取以下办法：<br/> 1.dmesg &#124; grep agp，如果出现:<br/> agp0: &nbsp;mem<br/> 0xe0000000-0xe3ffffff at device 0.0 on pci0<br/> 的字样，那么你的显卡就有可能实现3D功能.如果什么也没有的话，那么恭喜你，你再也不用为3D功能而费心了.<br/> 2.kldload drm，如果没报错的话，那么你的显卡基本上就可以实现3D功能了。<br/> c.3D功能的确认<br/> 运行：glxinfo。在第二行或第三行，如果出现”Direct Rendering: YES“字样，那就说明已经启用3D加速了。<br/> more /var/log/Xorg.0.log &#124; grep "direct rendering"如果出现下面的字样，(II) I810(0): direct rendering: Enabled那么你的3D就启用的。如果没有，<br/> 那么你要仔细读/var/log/Xorg.0.log。它会在某一行告诉你没启用的原因的。<br/> d.nvidia显卡驱动安装 cd /usr/ports/x11/nvidia-driver/<br/> 67.刷新率的问题，<br/> 将xorg.conf里的Modes行改成:Modes "1024x768"(小写的X)<br/> 选择默认的分辨率和色深。 这是在 "Screen" 小节中定义的：<br/> Section "Screen"<br/> Identifier "Screen0"<br/> Device &nbsp; &nbsp; "Card0"<br/> Monitor "Monitor0"<br/> DefaultDepth 24<br/> SubSection "Display"<br/> Viewport &nbsp; 0 0<br/> Depth &nbsp; &nbsp; 24<br/> Modes &nbsp; &nbsp; "1024x768"<br/> EndSubSection<br/> EndSection<br/> 68.make world<br/> cvsup -g -L 2 -h cvsup.freebsdchina.org standard-supfile &nbsp; (升级源码树)<br/> cp /usr/share/examples/etc/make.conf /etc/make.conf<br/> vi /etc/make.conf,保留如下内容<br/> CFLAGS= -O -pipe<br/> COPTFLAGS= -O -pipe<br/> cd /usr/src/sys/i386/conf &nbsp; (更改内核配置文件)<br/> cp GENERIC TDS<br/> vi TDS (按需要修改其内容)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> adjkerntz -i &nbsp; (确定本地时间设置)<br/> cd /usr/src<br/> make -j4 buildworld &nbsp; (编译基本系统)<br/> make buildkernel KERNCONF=TDS &nbsp; (编译新内核)<br/> make installkernel KERNCONF=TDS &nbsp; (安装新内核)<br/> reboot &nbsp; (重新启动)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> cd /usr/src<br/> mergemaster -p &nbsp; (更新/etc目录里的文件,-p预建模式)<br/> make installworld &nbsp; (安装新的二进制)<br/> mergemaster -Ui (更新makeinstallworld不更新的文件,-U進了6-STABLE了,這功能很讚，<br/> 就是他會看哪些/etc 的檔案，你沒有改過的，就會自動 merge，這樣子可以省下很多時間跟力氣。<br/> shutdown -r now &nbsp; (重新启动)<br/> uname -a &nbsp; (查看系统信息)<br/> cd /usr/src<br/> make cleanworld &nbsp; (清除升级过程产生的临时文件)<br/> #############################################<br/> 中断的 build 可以被恢复吗<br/> cd /usr/src<br/> make -DNOCLEAN all<br/> 这样就不会取消先前的 make buildworld 所做的工作。<br/> ##############################################<br/> 如果出现了错误我该怎么办？<br/> 删除以往的系统更新树<br/> cd /usr/obj<br/> chflags -R noschg *<br/> rm -rf *<br/> cd /usr/src<br/> make cleandir<br/> make cleandir<br/> 不错，make cleandir 真的要执行两次。<br/> 然后重新开始整个过程，使用 make buildworld 开始。<br/> mergemaster -p的说明<br/> mergemaster -p的作用是建立一个临时的根环境，把新的配置文件映射到这个环境当中，然后和系统的配置文件进行比较和处理，目的是保证系统配置文件的更新，这一点很重要！<br/> 在执行"mergemaster -p"的过程中，主要是进行以下处理：<br/> 检测系统是否存在临时的根环境，如果存在，让用户选择是利用现有的还是删除它，然后新建！<br/> *** The directory specified for the temporary root environment,<br/> /var/tmp/temproot, exists. This can be a security risk if untrusted<br/> users have access to the system.<br/> Use 'd' to delete the old /var/tmp/temproot and continue 删除旧的/var/tmp/temproot<br/> Use 't' to select a new temporary root directory 为temproot选择新的目录<br/> Use 'e' to exit mergemaster 退出mergemaster<br/> Default is to use /var/tmp/temproot as is<br/> How should I deal with this? [Use the existing /var/tmp/temproot]<br/> 一般的处理是选 "d" ，删除原有的目录，系统开始重新建立这个临时的根环境。<br/> 只要进行的不是大跨度的 FreeBSD 版本升级,可以简单地跳过这一步.<br/> mergemaster的说明<br/> 重新编译整个系统不会使用新的或改过的配置文件更新某些目录(尤其像 /etc,/var和/usr)更新这些文件最简单的方式就是使用 mergemaster，手工去做也是可以的，只要您愿意。<br/> 不管您选择哪一种，一定记得备份/etc 以防出错。<br/> mergemaster操作中可能会遇到以下操作提示:<br/> Use 'd' to delete the temporary 删除文件,不更新相应的系统配置文件<br/> Use 'i' to install the temporary 安装文件,使用新的配置文件覆盖旧文件<br/> Use 'm' to merge the temporary and installed versions 对旧的配置文件进行合并处理,并安装<br/> Use 'v' to view the diff results again 察看新文件与旧文件的差异<br/> ###跟踪多台机器,以A.B2个机器为例。A要启动nfs_server,B要启动nfs_client<br/> A:/etc/rc.conf<br/> rpcbind_enable="YES"<br/> nfs_server_enable="YES"<br/> /etc/exports<br/> /usr/src /usr/obj /usr/ports &nbsp; -maproot=0 &nbsp; 192.168.0.61(B-ip)<br/> B:/etc/rc.conf<br/> nfs_client_enable="YES"<br/> A.cd /usr/src<br/> make -j4 buildworld &nbsp; (编译基本系统)<br/> make buildkernel KERNCONF=TDS &nbsp; (编译新内核)<br/> B。mount b-ip:/usr/src /usr/src<br/> mount b-ip:/usr/obj /usr/obj<br/> cd /usr/src<br/> make installkernel KERNCONF=TDS &nbsp; (安装新内核)<br/> reboot &nbsp; (重新启动)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> cd /usr/src<br/> mergemaster -p &nbsp; (更新/etc目录里的文件,-p预建模式)<br/> make installworld &nbsp; (安装新的二进制)<br/> mergemaster -U &nbsp; (更新makeinstallworld不更新的文件,-U進了6-STABLE了,這功能很讚，<br/> 69.freebsd上下的jdk的安装方法(FreeBSD基金会提供的diablo-jdk)<br/> cd /usr/ports/java/diablo-jdk15<br/> 最好是通过port的diablo-jdk安装，而不是直接pkg_add，因为后者可能会出现依赖关系不对的问题。<br/> JDK与JRE的关系<br/> JAVA DEVELOPMENT KIT 与JAVA RUNTIME ENVIROMENT之间是什么关系？<br/> JRE只是Java的运行环境，而JDK是Java的开发、运行和调试一体的环境。<br/> JAVA环境变量的设置<br/> csh 就在/etc/csh.cshrc<br/> setenv JAVA_HOME /usr/local/diablo-jdk1.5.0<br/> setenv CLASS_PATH .:/usr/local/diablo-jdk1.5.0/lib/dt.jar<br/> bash就在/etc/profile<br/> export JAVA_HOME=/usr/local/diablo-jdk1.5.0<br/> #export CATALINA_HOME=/usr/local/jakarta-tomcat5<br/> export CLASSPATH=.JAVA_HOME/jre/lib/rt.jarJAVA_HOME/lib/dt.jarJAVA_HOME/lib/tools.jar<br/> 70.查找最快的cvsup站点<br/> cd /usr/ports/sysutils/fastest-cvsup<br/> make install clean<br/> fastest-cvsup -c jp,cn,hk,us<br/> 71.chmod 命令概解：chmod命令用于改变文件的运行级别(读=4写=2执行=1)<br/> chmod 400 files 给某文件以只读权限<br/> chmod 600 files 给某文件以只读、写权限<br/> chmod 700 files 给某文件以只读、写、执行权限<br/> chmod -R 400 directory 改变某目录下所有文件的运行权限为只读权限<br/> chmod -R 600 directory 改变某目录下所有文件的运行权限为以只读、写权限<br/> chmod -R 700 directory 改变某目录下所有文件的运行权限为只读、写、执行权限<br/> 72.chown概解：改变文件及文件夹的用户所属<br/> chown root:wheel files 改变文件的用户为root用户组为wheel组<br/> chown -R root:wheel directory 改变目录的用户为root用户组为wheel组<br/> 73.crontab 指令語法<br/> crontab [ -u user ] file<br/> crontab [ -u user ] { -l &#124; -r &#124; -e }<br/> crontab 提供我们在固定的间隔时间执行自订的程序、系统指令或 shell secrip。时间间隔的单位可以是分钟、<br/> 小时、日、周、月及以上的任意组合。允许使用者离线执行，并且可以将执行结果以 email 通知使用者。因此，<br/> 非常设合对周期性的管理分析或数据备份等工作。<br/> 基本上，crontab 的指令格式分为六个部分，前五个为时间间隔，最后则是执行的指令。每一个部分用空格来区隔。<br/> crontab -e : 执行文字编辑器来设定时程表，内定的文字编辑器是 VI，如果你想用别的文字编辑器，则请先设定<br/> VISUAL 环境变数来指定使用那个文字编辑器(比如说 setenv VISUAL joe)<br/> crontab -r : 删除目前的时程表<br/> crontab -l : 列出目前的时程表<br/> crontab file [-u user]-用指定的文件替代目前的crontab。<br/> 时程表的格式如下:<br/> f1 f2 f3 f4 f5 &nbsp; &nbsp; program<br/> 分 时 天 月 星期几 要执行的程序<br/> 当 f1 为 * 时表示每分钟都要执行 program，f2 为 * 时表示每小时都要执行程序，其馀类推<br/> 当 f1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行，f2 为 a-b 时表示从第 a 到第 b 小时都要执行，其馀类推<br/> 当 f1 为 */n 时表示每 n 分钟个时间间隔执行一次，f2 为 */n 表示每 n 小时个时间间隔执行一次，其馀类推<br/> 当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行，f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行，其馀类推<br/> 使用者也可以将所有的设定先存放在档案 file 中，用 crontab file 的方式来设定时程表。<br/> 先前曾提到，crontab 的格式分成六个部分，前五个是时间参数。在上例中你会发现除了数字与英文名称，<br/> 有使用到符号"*"，这个符号代表每一单位的意思，譬如30 3 * * *既代表30分3点每日每月星期的每天。<br/> 时间的指定，可以是单一的数字，或几个数字用逗号来连接。看下例<br/> 30 3,12 * * * /root/fbin/bak-web<br/> 其中的第二项为 3,12，这代表 3 以及 12 小时的意思。再来看下例<br/> 30 */6 * * * /root/fbin/bak-web<br/> 我把第二项改成 */6 这代表每 6 小时，也相当于 6,12,18,24 的作用。此外还有一个区段的做法<br/> 30 8-18/2 * * * /root/fbin/bak-web<br/> 我把第二项改成 8-18/2 这代表在 8 小时到 18 小时之间每 2 小时，也相当于 8,10,12,14,16,18 的作用<br/> 74.使用portsnap更新系统ports<br/> portsnap从6.0开始引进系统，给与用户方便的更新系统ports，portsnap的命令比较少,fetch 获取数据,extract 释放全部ports,update 更新ports<br/> 第一次使用可以portsnap fetch extract,以后使用可以portsnap fetch update国内镜像站<br/> portsnap.hshh.org<br/> portsnap2.hshh.org<br/> portsnap3.hshh.org (网通)<br/> 使用方法:<br/> /etc/portsnap.conf 里面更改<br/> SERVERNAME=portsnap.hshh.org<br/> 使用portupgrade 更新已安装的软件<br/> 75.清屏<br/> clear或ctrl+L<br/> 76.freebsd 怎么安装GF4 MX 440的显卡<br/> 首先更新ports和src，到/usr/ports/x11/nvidia-driver下make install clean，要選中linux的支持。<br/> 然后到/usr/ports/x11/nvidia-xconfig下make install clean，還可以到/usr/ports/x11/nvidia-settings下安裝控制面板。<br/> 運行nvidia-xconfig會自動生成xorg.conf文件，然后根据需要自行更改。<br/> 77.如何知道一个文件属于哪个port，比如libplds4.so.1<br/> pkg_info -W filename<br/> 78.mplayer<br/> cd /usr/ports/multimedia/mplayer<br/> make install clean<br/> 问题：如何让mplayer支持srt格式的字幕？<br/> 解答：首先复制一个中文ttf字体文件到 ~/.mplayer/ 目录下，并改名为 subfont.ttf ；然后在gmplayer的选项<br/> (Preferences)->Subtitle & OSD 中将 Encoding 项选为“Simplified Chinese charset (CP936)”。如果你还使用命令行播放电影，还需要在 ~/.mplayer/config 文件中加上这么一行：subcp=cp936 。如果仍然不能显示字幕，请看看字幕文件名和电影文件名是否相配：如果avi文件是movie.avi的话，字幕文件名应该是movie.srt。<br/> 问题：怎么mplayer不能显示.idx+.rar格式的字幕？<br/> 解答：先将rar文件中的sub文件解压出来 。<br/> 问题：如何让mplayer的播放窗口保持在最前面？<br/> 解答：修改 ~/.mplayer/config 文件，加上这么一行：ontop=yes 。<br/> 问题：如何让mplayer的画面随窗口大小自动缩放呢？<br/> 解答：修改 ~/.mplayer/config 文件，加上这么一行：zoom=yes。<br/> 测试通过by tds 061119。fb61+xorg6.9+xfce4+gmplayer<br/> 79.设置控制台高分辩率<br/> 1.在内核配制文件里加入下面的编译内核<br/> options &nbsp; &nbsp;VESA<br/> options &nbsp; &nbsp;SC_PIXEL_MODE<br/> 第一行选项让內核支持VESA 2，第二行让内核支持控制台图形模式。<br/> 2.vidcontrol -i mode 查询出所有模式<br/> ......<br/> 279 (0x117) 0x0000000f G 1024x768x16 1 8x16 &nbsp; 0xa0000 64k 64k 0xd8000000 65536k<br/> 280 (0x11 0x0000000f G 1024x768x32 1 8x16 &nbsp; 0xa0000 64k 64k 0xd8000000 65536k<br/> ......<br/> 3.测试模式<br/> vidcontrol MODE_280<br/> 4.vi /etc/rc.conf加入下面这条<br/> allscreens_flags="MODE_280"<br/> 5.把console改成黑底绿字的<br/> vidcontrol green<br/> 80.设置FreeBSD console下的字体大小<br/> vidcontrol -f ...<br/> 81.锁住终端<br/> lock -np<br/> -n 永不超时,-p 使用系统密码作为开启终端的密匙<br/> 82.刻录CD ISO映像文件<br/> burncd -f /dev/acd0 -s max data imagefile.iso fixate<br/> 刻录一个文件到CD上而不创建ISO9660文件系统<br/> burncd -f /dev/acd1 -s 12 data archive.tar.gz fixate<br/> 生成ISO文件<br/> mkisofs -o imagefile.iso /path/to/tree<br/> 把数据CD复制成一个与之等价的镜像文件<br/> dd if=/dev/acd0 of=file.iso bs=2048<br/> 83.类似flashget的东东download for X，d4x<br/> /usr/ports/ftp/downloader<br/> 84.使用watch监视终端<br/> 1.编辑核心加入pseudo-device snp或者kldload snp<br/> 2.cd /dev &nbsp; ./MAKEDEV snp0 snp1<br/> 3.watch ttyp1<br/> 去换终端ctrl-x<br/> 退出watch ctrl-g<br/> 85.kldload xxx 加载xxx模块<br/> kldstat 查看已加载的模块<br/> kldunload xxx 从核心中移除<br/> 86.让程序读取新的配置文件<br/> kill -HUP 199 &nbsp; &nbsp; &nbsp; &nbsp;(进称号)<br/> killall -HUP sshd (进程名)<br/> 上述指令中的参数 -HUP 也可以使用 -1 来取代<br/> 87.登入后的讯息Message Of The Day(motd)<br/> 编辑 /etc/motd 来制作自己的画面<br/> 登入前的讯息<br/> 修改 /etc/gettytab 及 /etc/issue<br/> 编辑 /etc/gettytab，找到 default的地方。<br/> default:&#92;:cb:ce:ck:lc:fd#1000:im=&#92;r&#92;n%s/%m (%h) (%t)&#92;r&#92;n&#92;r&#92;n:sp#1200:&#92;<br/> :if=/etc/issue:<br/> 其中的%s %m %h %t分别对应到FreeBSD i386 example.com ttyp0，如果你不想显示FreeBSD，<br/> 就把%s拿掉。最后一行if=/etc/issue就是表如果没有issue这个档的话，就执行default。<br/> 88.变更自己所使用的Shell<br/> chsh -s /bin/tcsh<br/> 上述指令将Shell变更成/bin/tcsh。注意!输入的shell名称一定要存在于/etc/shells中<br/> 89.Shell 的环境变量<br/> tcsh可以使用setenv看目前所有的环境变量，也可以使用setenv来改变一个环境变量的值<br/> setenv EDITOR ee<br/> 如果您使用的是 Bourne Shell：<br/> export EDITOR="ee"<br/> 90./etc/master.passwd 介绍<br/> FreeBSD使用shadow password的方式来保护密码文件，只有root才可以读取编码后的密码文件/etc/master.passwd。但是这并不是系统用来验证的档案，为了加快速度，FreeBSD将该文件做成数据库/etc/spwd.db及/etc/pwd.db，因此在修改完master.passwd后，必须使用指令pwd_mkdb来将master.passwd做成数据库档案。不过一般而言，我会使用vipw这个指令来修改master.passwd，vipw会先将master.passwd以预设的文书编辑软件打开，修改完存盘后，它会视需要自动更新数据库。<br/> pwd_mkdb -p -d /etc /etc/master.passwd<br/> master.passwd这个档案内容中，每个使用者都是独立的一行，每个字段使用冒号分开，格式是：<br/> name:password:UID:GID:class:change:expire:fullname:home:shell<br/> pwd_mkdb介绍<br/> 如果我们直接以文书编辑软件来修改/etc/master.passwd，在修改完后，必须执行pwd_mkdb来将更新的数据做成系统可以读取的数据库文件。pwd_mkdb还会自动建立/etc/passwd。<br/> 91.将使用者目录拥有者更改为所属的使用者<br/> chown -R user:group /home/user<br/> 使用参数-R将目录user及其下所有档案及子目录的拥有人改变成user<br/> 92.记录使用者指令<br/> 修改 /etc/rc.conf，加上下列一行设定：<br/> accounting_enable="YES"<br/> 系统会将使用者的历程记录在/var/account/acct*中，最新的记录是acct<br/> 当下达指令lastcomm时，则系统会以/var/account/acct为参考，印出所记录的数据。<br/> 也可以使用lastcomm -f acct1来查看前一天的资料。<br/> 93.sudo<br/> 如果你希望它能将执行sudo的log记下来的话，必须先编辑/usr/ports/security/sudo/Makefile，<br/> 将CONFIGURE_ARGS中的参数 --disable-log-wrap 拿掉。<br/> cd /usr/ports/security/sudo<br/> make install clean<br/> 安装完后，我们要先执行/usr/local/sbin/visudo以设定sudo的设定档(/usr/loca/etc/sudoers)。设定完后，使用者即可执行sudo ，使用者只要输入自己的密码即可，不必知道root密码，而且5分钟内再次执行sudo时不需再输入密码。如果你有打开log记录功能，sudo执行成功或失败的log都将被记录到/var/log/sudo.log中。<br/> 94./usr/ports/dns/ddclient动态dns更新软件<br/> 95.SCSI工具camcontrol<br/> camcontrol devlist 查看目前所有USB装置<br/> ATA工具<br/> atacontrol list 查看目前所有ATA装置<br/> 96.如果我们只知道一个关键词，却不知要使用哪一个指令，我们可以使用参数k来查询。<br/> 例如我们要查询 firewall 相关的指令：man -k firewall<br/> 97.bg<br/> 将指定的程序放入背景中执行。当我们下达一个指令后，必须要等待该程序结束后才能输入下一个命令。<br/> 如果该程序必须执行一段很长的时间，我们不想等程序结束，可以把它放到背景中执行。在下达指令后，按 Ctrl+Z 来暂停程序，接着再执行 bg 即可将程序放到背景中执行。<br/> $ sleep 1000<br/> ^Z<br/> Suspended<br/> $ bg<br/> [1] sleep 1000 &<br/> 我们也可以在所要执行的指令后面加上符号 "&"，就可以将该程序放到背景执行：<br/> $ sleep 1000 &<br/> [2] 46461<br/> 98.jobs<br/> jobs 指令可以让我们查询目前有哪些程序在背景执行。如果加入参数 -l 可以得到 PID 的信息。<br/> jobs -l<br/> [1] + 46459 Running sleep 1000<br/> [2] - 46461 Running sleep 1500<br/> 99.fg<br/> 将指定的程序放到前景中执行。我们使用jobs看到目前在背景执行的程序之后，可以使用fg把它叫回前景。<br/> 例如要叫回第一个在背景中执行的程序：<br/> fg %1<br/> sleep 1000<br/> 100.sync<br/> 让系统暂存的数据强制存回硬盘<br/> 101.cp -Rp sourdir tardir<br/> -R完成递归复制(即可以复制目录以下的所有内容)，-p保留文件的时间、所属等等<br/> 102.ssh<br/> [email=username@hostname]username@hostname[/email]<br/> 从远程拷贝 scp<br/> [email=user@host:/path/to/files]user@host:/path/to/files[/email]<br/> local_file_name<br/> 拷贝到远程 scp local_file_name<br/> [email=user@host:/path/to/files]user@host:/path/to/files[/email]<br/> <br/>103.使用Portaudit监视第三方安全问题<br/> cd /usr/ports/security/portaudit && make install clean<br/> 安装完成之后更新数据库<br/> portaudit -Fda<br/> 使用下面的命令对通过Ports Collection安装的第三方软件工具进行审计<br/> portaudit -a<br/> 104.我要怎么从 X 切换到 virtual consoles？<br/> 请用Ctrl+Alt+Fn以切回至console。Ctrl+Alt+F1可以切回至第一个console。<br/> 当你切回至文字console后，你就可以使用一般的Alt+Fn组合键在各console之间切换了。<br/> 要回到X的话，你就可以使用Alt+F9以返回至X中。<br/> 105.FB下Free的杀毒软件<br/> clamav (security/clamav)<br/> man clamscan 扫描<br/> man freshclam 更新病毒库<br/> man clamd<br/> man clamdscan<br/> man sigtool<br/> 配置文件<br/> /use/local/etc/freshclam.conf<br/> /usr/local/etc/clamd.conf<br/> 把conf里的#Example去掉<br/> # Comment or remove the line below.<br/> #Example<br/> /etc/rc.conf加入<br/> clamav_clamd_enable="YES"<br/> clamav_freshclam_enable="YES"<br/> 106.软件默认配置示例文件的一般存放位置<br/> /usr/share/examples<br/> /usr/local/share/examples<br/> 107.安装文泉驿字体<br/> cd /usr/ports/x11-fonts/wqy/<br/> make install clean<br/> 108.把/data/tftp打包成pxeinstfb62.tgz<br/> cd /data/<br/> tar zcvf pxeinstfb62.tgz tftp<br/> 解压<br/> tar zxvf pxeinstfb62.tgz<br/> 109.ports下有没有xxx这个软件？在哪个目录下？<br/> 回答：有两种办法来查找，一是通过软件名：<br/> make fetchindex<br/> cd /usr/ports<br/> make search name=xxx &#124; grep ^Path<br/> 另一种是通过关键字，也就是在软件名和说明中只要包括这个单词的都会查找出来：<br/> cd /usr/ports<br/> make search key=xxx &#124; grep ^Path<br/> 110.FreeBSD如何获得硬件信息?<br/> sysctl -a &#124; grep "^dev&#92;."<br/> pciconf -lv<br/>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?629</link>
<title><![CDATA[freebsd10 更新ports]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 28 Jan 2015 09:48:17 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?629</guid> 
<description>
<![CDATA[ 
	使用最新的ports可以保证软件的互相依赖，升级的命令也比以前的版本简单了很多。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#portsnap fetch extract</div></div><br/>会下载一个70M的包，解压后就升级好了。
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?628</link>
<title><![CDATA[freebsd10下安装Nginx+php56+mysql56]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 28 Jan 2015 09:42:43 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?628</guid> 
<description>
<![CDATA[ 
	freebsd10下安装Nginx+php56+mysql56其实很简单，只是很多PHP组件怎么装？网上少有提及，我来给大家一个比较全的安装命令吧。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">pkg install nginx php56 php56-extensions php56-mysql php56-mysqli php56-mbstring php56-soap php56-gd php56-curl php56-bz2 php56-mcrypt php56-xsl php56-ftp php56-pdo_mysql php56-sockets php56-tidy mysql56-server</div></div><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">pkg install nginx php70 php70-extensions php70-mysqli php70-mbstring php70-soap php70-gd php70-curl php70-bz2 php70-mcrypt php70-xsl php70-ftp php70-pdo_mysql php70-sockets php70-tidy mysql57-server</div></div><br/>这样一句命令就把这些都装完了。剩下的就是配置了。<br/>首先在启动中加入开启服务命名。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /etc/rc.conf<br/>在最后加入下面三句<br/>nginx_enable="YES"<br/>php_fpm_enable="YES"<br/>mysql_enable="YES"</div></div><br/>完成下面的步骤，才可以重启服务器啊，否则会有rc.conf报错<br/>配置mysql<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /usr/local/etc/my.cnf<br/>[mysqld]<br/>socket = /tmp/mysql.sock<br/><br/>skip-networking<br/>skip-name-resolve<br/>然后启动mysql<br/># service mysql-server start<br/>修改root的密码<br/># /usr/local/bin/mysqladmin -u root password '你的密码'</div></div><br/>配置 PHP <br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini<br/># ee php.ini<br/>修改post_max_size = 200M<br/>upload_max_filesize = 200M<br/>max_file_uploads = 100<br/>display_errors = On</div></div><br/>配置php-fpm<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/># ee /usr/local/etc/php-fpm.conf<br/>修改<br/>pm.max_children = 300<br/>pm.start_servers = 20<br/>pm.min_spare_servers = 5<br/>pm.max_spare_servers = 35<br/>pm.max_requests = 10240<br/>启动php-fpm<br/># service php-fpm start</div></div><br/>配置Nginx<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>建立日志目录<br/># mkdir /var/log/nginx/<br/>编辑nginx配置文件<br/># ee /usr/local/etc/nginx/nginx.conf<br/>写入下面内容<br/>user &nbsp;www www;<br/>worker_processes 8;<br/>worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;<br/>worker_rlimit_nofile 204800;<br/><br/>#error_log &nbsp;logs/error.log;<br/>#error_log &nbsp;logs/error.log &nbsp;notice;<br/>#error_log &nbsp;logs/error.log &nbsp;info;<br/><br/>pid &nbsp; &nbsp; &nbsp; &nbsp;/var/run/nginx.pid;<br/><br/><br/>events {<br/> &nbsp; &nbsp;use kqueue;<br/> &nbsp; &nbsp;multi_accept on;<br/> &nbsp; &nbsp;worker_connections &nbsp;204800;<br/>}<br/><br/><br/>http {<br/> &nbsp; &nbsp;server_tokens off;<br/> &nbsp; &nbsp;sendfile on;<br/> &nbsp; &nbsp;tcp_nopush on;<br/> &nbsp; &nbsp;tcp_nodelay on;<br/><br/> &nbsp; &nbsp;access_log off;<br/> &nbsp; &nbsp;error_log /var/log/nginx/error.log crit;<br/><br/> &nbsp; &nbsp;keepalive_timeout 60;<br/> &nbsp; &nbsp;client_header_timeout 10;<br/> &nbsp; &nbsp;client_body_timeout 10;<br/> &nbsp; &nbsp;reset_timedout_connection on;<br/> &nbsp; &nbsp;send_timeout 10;<br/><br/> &nbsp; &nbsp;limit_conn_zone $binary_remote_addr zone=addr:5m;<br/> &nbsp; &nbsp;limit_conn addr 100;<br/><br/> &nbsp; &nbsp;include mime.types;<br/> &nbsp; &nbsp;default_type application/octet-stream;<br/> &nbsp; &nbsp;charset UTF-8;<br/><br/> &nbsp; &nbsp;gzip on;<br/> &nbsp; &nbsp;gzip_disable "msie6";<br/> &nbsp; &nbsp;gzip_proxied any;<br/> &nbsp; &nbsp;gzip_min_length 1k;<br/> &nbsp; &nbsp;gzip_buffers 4 16k;<br/> &nbsp; &nbsp;gzip_comp_level 6;<br/> &nbsp; &nbsp;gzip_vary on;<br/> &nbsp; &nbsp;gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;<br/><br/> &nbsp; &nbsp;open_file_cache max=204800 inactive=20s;<br/> &nbsp; &nbsp;open_file_cache_valid 30s;<br/> &nbsp; &nbsp;open_file_cache_min_uses 2;<br/> &nbsp; &nbsp;open_file_cache_errors on;<br/> &nbsp; &nbsp;server_names_hash_bucket_size 128;<br/> &nbsp; &nbsp;client_header_buffer_size 2k;<br/> &nbsp; &nbsp;large_client_header_buffers 4 4k;<br/> &nbsp; &nbsp;client_max_body_size 8m;<br/> &nbsp; &nbsp;fastcgi_connect_timeout 300;<br/> &nbsp; &nbsp;fastcgi_send_timeout 300;<br/> &nbsp; &nbsp;fastcgi_read_timeout 300;<br/> &nbsp; &nbsp;fastcgi_buffer_size 4k;<br/> &nbsp; &nbsp;fastcgi_buffers 8 4k;<br/> &nbsp; &nbsp;fastcgi_busy_buffers_size 8k;<br/> &nbsp; &nbsp;fastcgi_temp_file_write_size 8k;<br/> &nbsp; &nbsp;fastcgi_cache_valid 200 302 1h;<br/> &nbsp; &nbsp;fastcgi_cache_valid 301 1d;<br/> &nbsp; &nbsp;fastcgi_cache_valid any 1m;<br/> &nbsp; &nbsp;fastcgi_cache_min_uses 1;<br/> &nbsp; &nbsp;upstream fastcgi_backend {<br/> &nbsp; &nbsp; &nbsp; &nbsp;server 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; &nbsp;keepalive 60;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#include &nbsp; &nbsp; &nbsp; mime.types;<br/> &nbsp; &nbsp;#default_type &nbsp;application/octet-stream;<br/><br/> &nbsp; &nbsp;#log_format &nbsp;main &nbsp;'$remote_addr - $remote_user [$time_local] "$request" '<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'$status $body_bytes_sent "$http_referer" '<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$http_user_agent" "$http_x_forwarded_for"';<br/><br/> &nbsp; &nbsp;#access_log &nbsp;logs/access.log &nbsp;main;<br/><br/> &nbsp; &nbsp;#sendfile &nbsp; &nbsp; &nbsp; &nbsp;on;<br/> &nbsp; &nbsp;#tcp_nopush &nbsp; &nbsp; on;<br/><br/> &nbsp; &nbsp;#keepalive_timeout &nbsp;0;<br/> &nbsp; &nbsp;#keepalive_timeout &nbsp;65;<br/><br/> &nbsp; &nbsp;#gzip &nbsp;on;<br/><br/> &nbsp; &nbsp;server {<br/> &nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 80;<br/> &nbsp; &nbsp; &nbsp; &nbsp;server_name &nbsp;localhost;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#charset koi8-r;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#access_log &nbsp;logs/host.access.log &nbsp;main;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; /usr/local/www/nginx;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm index.php;<br/> &nbsp; &nbsp; &nbsp;#try_files $uri $uri/ /index.php$uri?$args;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#error_page &nbsp;404 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/404.html;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# redirect server error pages to the static page /50x.html<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;error_page &nbsp; 500 502 503 504 &nbsp;/50x.html;<br/> &nbsp; &nbsp; &nbsp; &nbsp;location = /50x.html {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; /usr/local/www/nginx-dist;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp;location ~ ^/(status)$ {<br/> &nbsp; &nbsp; &nbsp; access_log off;<br/> &nbsp; &nbsp; &nbsp; include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp; fastcgi_pass 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; fastcgi_param SCRIPT_FILENAME /usr/loca/www/nginx$fastcgi_script_name;<br/> &nbsp;}<br/><br/> &nbsp;location /myadmin {<br/> &nbsp; &nbsp; &nbsp; alias /usr/local/www/phpMyAdmin;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index index.php;<br/> &nbsp;}<br/> &nbsp;location ~ /myadmin/.+&#92;.php$ {<br/> &nbsp; &nbsp; &nbsp; if ($fastcgi_script_name ~ /myadmin/(.+&#92;.php.*)$) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $valid_fastcgi_script_name $1;<br/> &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp; fastcgi_pass &nbsp; 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; fastcgi_index &nbsp;index.php;<br/> &nbsp; &nbsp; &nbsp; fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin/$valid_fastcgi_script_name;<br/> &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp;# proxy the PHP scripts to Apache listening on 127.0.0.1:80<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;#location ~ &#92;.php$ {<br/> &nbsp; &nbsp; &nbsp; &nbsp;# &nbsp; &nbsp;proxy_pass &nbsp; http://127.0.0.1;<br/> &nbsp; &nbsp; &nbsp; &nbsp;#}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;location ~ &#92;.php$ {<br/> &nbsp; &nbsp; &nbsp;fastcgi_pass 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp;fastcgi_index index.php;<br/> &nbsp; &nbsp; &nbsp;include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp;fastcgi_split_path_info ^(.+&#92;.php)(/?.*)$;<br/> &nbsp; &nbsp; &nbsp;fastcgi_param PATH_INFO $fastcgi_path_info; &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp;fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html;<br/> &nbsp; &nbsp; &nbsp;#fastcgi_pass fastcgi_backend;<br/> &nbsp; &nbsp; &nbsp;#fastcgi_keep_conn on;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# deny access to .htaccess files, if Apache's document root<br/> &nbsp; &nbsp; &nbsp; &nbsp;# concurs with nginx's one<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;#location ~ /&#92;.ht {<br/> &nbsp; &nbsp; &nbsp; &nbsp;# &nbsp; &nbsp;deny &nbsp;all;<br/> &nbsp; &nbsp; &nbsp; &nbsp;#}<br/> &nbsp; &nbsp;}<br/><br/><br/> &nbsp; &nbsp;# another virtual host using mix of IP-, name-, and port-based configuration<br/> &nbsp; &nbsp;#<br/> &nbsp; &nbsp;#server {<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 8000;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; somename:8080;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;server_name &nbsp;somename &nbsp;alias &nbsp;another.alias;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#}<br/><br/><br/> &nbsp; &nbsp;# HTTPS server<br/> &nbsp; &nbsp;#<br/> &nbsp; &nbsp;#server {<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 443 ssl;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;server_name &nbsp;localhost;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_certificate &nbsp; &nbsp; &nbsp;cert.pem;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_certificate_key &nbsp;cert.key;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_session_cache &nbsp; &nbsp;shared:SSL:1m;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_session_timeout &nbsp;5m;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_ciphers &nbsp;HIGH:!aNULL:!MD5;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_prefer_server_ciphers &nbsp;on;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#}<br/><br/>}<br/>启动nginx<br/># service nginx start</div></div><br/>测试是否工作正常<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /usr/local/www/nginx/info.php<br/>写入下面的内容<br/><div class="code">&lt;?php phpinfo(); ?&gt;</div><br/>用浏览器访问http://IP/info.php，如果能看到就说明工作正常了。</div></div><br/>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?613</link>
<title><![CDATA[Apache Rewrite解决问号匹配的写法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 05 Nov 2012 09:33:35 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?613</guid> 
<description>
<![CDATA[ 
	<p>这个问题我用了一个上午终于解决了，需求是这样的：</p><p>A地址：域名/ProductView.jsp?lClassID=200</p><p>B地址：域名/goods.php?id=3</p><p>实现把用户输A地址跳到B地址，就是跳转的功能。</p><p>原先用我用最常的方法实现如：RewriteRule ^ProductView.jsp?lClassID=200$&nbsp;&nbsp;&nbsp; goods.php?id=3 [L]<br />看上去是没有问题的，但在地址上输入跳转不了。后来网上查了一下资料如下：</p><p>规则： <br />引用自 <br />文本<br />. 任意一个单字符<br />[chars] 字符类: &quot;chars&quot;中的任意一个字符<br />[^chars] 字符类: 不在&quot;chars&quot;中的字符<br />text1&#124;text2 选择: text1 或 text2</p><p>量词<br />? 前面的字符出现 0 或 1 次<br />* 前面的字符出现 0 或 N 次(N &gt; 0)<br />+ 前面的字符出现 1 或 N 次(N &gt; 1</p><p>原来这样：?号把前面的p也作为参数了，p?（&#92;?）就变成了$1,当在地址中输入<a href="http://www.geekso.com/ProductView.jslClassID=200">http://www.geekso.com/ProductView.jslClassID=200</a> 可实现跳转,但这显然不是需求那样的.<br />本来都想放弃用重写了，在网上又找了一下终于找到了，功夫不负有心人啊，<br />解决方法如下：</p><p>RewriteCond %{QUERY_STRING} ^lClassID=200$<br />RewriteRule ^ProductView&#92;.jsp$ goods&#92;.php&#92;?id=3 [L]</p><p>我找到的相关资料:</p><p>把 /abc?id=123&nbsp; =&gt;&nbsp; /def.php?id=123 的写法：</p><p>RewriteEngine on<br />RewriteCond %{QUERY_STRING} ^id=(.+)$<br />RewriteRule ^/abc$ /def.php?sid=%1 [L]</p><p>RewriteRule 不会去匹配 ? 后面的字符串，需要用RewriteCond来匹配<br /></p><br/>Tags - <a href="tag.php?tag=apache" rel="tag">apache</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?598</link>
<title><![CDATA[查看 Apache并发请求数及其TCP连接状态]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Tue, 17 Apr 2012 07:46:45 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?598</guid> 
<description>
<![CDATA[ 
	服务器上的一些统计数据：<br/><br/>1)统计80端口连接数<br/>netstat -nat&#124;grep -i "80"&#124;wc -l<br/><br/>2）统计httpd协议连接数<br/>ps -ef&#124;grep httpd&#124;wc -l<br/><br/>3）、统计已连接上的，状态为“established<br/>netstat -na&#124;grep ESTABLISHED&#124;wc -l<br/><br/>4)、查出哪个IP地址连接最多,将其封了.<br/>netstat -na&#124;grep ESTABLISHED&#124;awk {print $5}&#124;awk -F: {print $1}&#124;sort&#124;uniq -c&#124;sort -r +0n<br/><br/>netstat -na&#124;grep SYN&#124;awk {print $5}&#124;awk -F: {print $1}&#124;sort&#124;uniq -c&#124;sort -r +0n<br/><br/>---------------------------------------------------------------------------------------------<br/><br/>1、查看apache当前并发访问数：<br/>netstat -an &#124; grep ESTABLISHED &#124; wc -l<br/><br/>对比httpd.conf中MaxClients的数字差距多少。<br/><br/>2、查看有多少个进程数：<br/>ps aux&#124;grep httpd&#124;wc -l<br/><br/>3、可以使用如下参数查看数据<br/>server-status?auto<br/><br/>#ps -ef&#124;grep httpd&#124;wc -l<br/>1388<br/>统计httpd进程数，连个请求会启动一个进程，使用于Apache服务器。<br/>表示Apache能够处理1388个并发请求，这个值Apache可根据负载情况自动调整。<br/><br/>#netstat -nat&#124;grep -i "80"&#124;wc -l<br/>4341<br/>netstat -an会打印系统当前网络链接状态，而grep -i "80"是用来提取与80端口有关的连接的，wc -l进行连接数统计。<br/>最终返回的数字就是当前所有80端口的请求总数。<br/><br/>#netstat -na&#124;grep ESTABLISHED&#124;wc -l<br/>376<br/>netstat -an会打印系统当前网络链接状态，而grep ESTABLISHED 提取出已建立连接的信息。 然后wc -l统计。<br/>最终返回的数字就是当前所有80端口的已建立连接的总数。<br/><br/>netstat -nat&#124;&#124;grep ESTABLISHED&#124;wc - 可查看所有建立连接的详细记录<br/><br/>查看Apache的并发请求数及其TCP连接状态：<br/>　　Linux命令：<br/>netstat -n &#124; awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'<br/><br/>（这条语句是从 新浪互动社区事业部 新浪互动社区事业部技术总监王老大那儿获得的，非常不错）返回结果示例：<br/>　　LAST_ACK 5<br/>　　SYN_RECV 30<br/>　　ESTABLISHED 1597<br/>　　FIN_WAIT1 51<br/>　　FIN_WAIT2 504<br/>　　TIME_WAIT 1057<br/>　　其中的<br/>SYN_RECV表示正在等待处理的请求数；<br/>ESTABLISHED表示正常数据传输状态；<br/>TIME_WAIT表示处理完毕，等待超时结束的请求数。<br/><br/>---------------------------------------------------------------------------------------------<br/><br/>查看Apache并发请求数及其TCP连接状态<br/><br/>查看httpd进程数（即prefork模式下Apache能够处理的并发请求数）：<br/>　　Linux命令：<br/><br/>ps -ef &#124; grep httpd &#124; wc -l<br/><br/>　　返回结果示例：<br/>　　1388<br/>　　表示Apache能够处理1388个并发请求，这个值Apache可根据负载情况自动调整，我这组服务器中每台的峰值曾达到过2002。<br/> <br/>查看Apache的并发请求数及其TCP连接状态：<br/>　　Linux命令：<br/> <br/>netstat -n &#124; awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'<br/>返回结果示例：<br/>　　LAST_ACK 5<br/>　　SYN_RECV 30<br/>　　ESTABLISHED 1597<br/>　　FIN_WAIT1 51<br/>　　FIN_WAIT2 504<br/>　　TIME_WAIT 1057<br/>　　其中的SYN_RECV表示正在等待处理的请求数；ESTABLISHED表示正常数据传输状态；TIME_WAIT表示处理完毕，等待超时结束的请求数。<br/>　　状态：描述<br/><br/>　　CLOSED：无连接是活动 的或正在进行<br/><br/>　　LISTEN：服务器在等待进入呼叫<br/><br/>　　SYN_RECV：一个连接请求已经到达，等待确认<br/><br/>　　SYN_SENT：应用已经开始，打开一个连接<br/><br/>　　ESTABLISHED：正常数据传输状态<br/><br/>　　FIN_WAIT1：应用说它已经完成<br/><br/>　　FIN_WAIT2：另一边已同意释放<br/><br/>　　ITMED_WAIT：等待所有分组死掉<br/><br/>　　CLOSING：两边同时尝试关闭<br/><br/>　　TIME_WAIT：另一边已初始化一个释放<br/><br/>　　LAST_ACK：等待所有分组死掉<br/><br/> <br/><br/>如发现系统存在大量TIME_WAIT状态的连接，通过调整内核参数解决，<br/>vim /etc/sysctl.conf<br/>编辑文件，加入以下内容：<br/>net.ipv4.tcp_syncookies = 1<br/>net.ipv4.tcp_tw_reuse = 1<br/>net.ipv4.tcp_tw_recycle = 1<br/>net.ipv4.tcp_fin_timeout = 30<br/>然后执行 /sbin/sysctl -p 让参数生效。<br/><br/>net.ipv4.tcp_syncookies = 1 表示开启SYN cookies。当出现SYN等待队列溢出时，启用cookies来处理，可防范少量SYN攻击，默认为0，表示关闭；<br/>net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接，默认为0，表示关闭；<br/>net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收，默认为0，表示关闭。<br/>net.ipv4.tcp_fin_timeout 修改系統默认的 TIMEOUT 时间<br/>下面附上TIME_WAIT状态的意义：<br/><br/>客户端与服务器端建立TCP/IP连接后关闭SOCKET后，服务器端连接的端口<br/>状态为TIME_WAIT<br/><br/>是不是所有执行主动关闭的socket都会进入TIME_WAIT状态呢？<br/>有没有什么情况使主动关闭的socket直接进入CLOSED状态呢？<br/><br/>主动关闭的一方在发送最后一个 ack 后<br/>就会进入 TIME_WAIT 状态 停留2MSL（max segment lifetime）时间<br/>这个是TCP/IP必不可少的，也就是“解决”不了的。<br/><br/>也就是TCP/IP设计者本来是这么设计的<br/>主要有两个原因<br/>1。防止上一次连接中的包，迷路后重新出现，影响新连接<br/>（经过2MSL，上一次连接中所有的重复包都会消失）<br/>2。可靠的关闭TCP连接<br/>在主动关闭方发送的最后一个 ack(fin) ，有可能丢失，这时被动方会重新发<br/>fin, 如果这时主动方处于 CLOSED 状态 ，就会响应 rst 而不是 ack。所以<br/>主动方要处于 TIME_WAIT 状态，而不能是 CLOSED 。<br/><br/>TIME_WAIT 并不会占用很大资源的，除非受到攻击。<br/><br/>还有，如果一方 send 或 recv 超时，就会直接进入 CLOSED 状态<br/><br/>如何合理设置apache httpd的最大连接数？<br/><br/>手头有一个网站在线人数增多，访问时很慢。初步认为是服务器资源不足了，但经反复测试，一旦连接上，不断点击同一个页面上不同的链接，都能迅速打开，这种现象就是说明apache最大连接数已经满了，新的访客只能排队等待有空闲的链接，而如果一旦连接上，在keeyalive 的存活时间内（KeepAliveTimeout，默认5秒）都不用重新打开连接，因此解决的方法就是加大apache的最大连接数。<br/><br/>1.在哪里设置？<br/>apache 2.24，使用默认配置（FreeBSD 默认不加载自定义MPM配置），默认最大连接数是250<br/><br/>在/usr/local/etc/apache22/httpd.conf中加载MPM配置（去掉前面的注释）：<br/># Server-pool management (MPM specific)<br/>Include etc/apache22/extra/httpd-mpm.conf<br/><br/>可见的MPM配置在/usr/local/etc/apache22/extra/httpd-mpm.conf，但里面根据httpd的工作模式分了很多块，哪一部才是当前httpd的工作模式呢？可通过执行 apachectl -l 来查看：<br/>Compiled in modules:<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;core.c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prefork.c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http_core.c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mod_so.c<br/><br/>看到prefork 字眼，因此可见当前httpd应该是工作在prefork模式，prefork模式的默认配置是：<br/><IfModule mpm_prefork_module><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MinSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;150<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxRequestsPerChild &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br/></IfModule><br/><br/>2.要加到多少？<br/><br/>连接数理论上当然是支持越大越好，但要在服务器的能力范围内，这跟服务器的CPU、内存、带宽等都有关系。<br/><br/>查看当前的连接数可以用：<br/>ps aux &#124; grep httpd &#124; wc -l<br/><br/>或：<br/>pgrep httpd&#124;wc -l<br/><br/>计算httpd占用内存的平均数:<br/>ps aux&#124;grep -v grep&#124;awk '/httpd/{sum+=$6;n++};END{print sum/n}'<br/><br/>由于基本都是静态页面，CPU消耗很低，每进程占用内存也不算多，大约200K。<br/><br/>服务器内存有2G，除去常规启动的服务大约需要500M（保守估计），还剩1.5G可用，那么理论上可以支持1.5*1024*1024*1024/200000 = 8053.06368<br/><br/>约8K个进程，支持2W人同时访问应该是没有问题的（能保证其中8K的人访问很快，其他的可能需要等待1、2秒才能连上，而一旦连上就会很流畅）<br/><br/>控制最大连接数的MaxClients ，因此可以尝试配置为：<br/><IfModule mpm_prefork_module><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MinSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5500<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5000<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxRequestsPerChild &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 100<br/></IfModule><br/><br/>注意，MaxClients默认最大为250，若要超过这个值就要显式设置ServerLimit，且ServerLimit要放在MaxClients之前，值要不小于MaxClients，不然重启httpd时会有提示。<br/><br/>重启httpd后，通过反复执行pgrep httpd&#124;wc -l 来观察连接数，可以看到连接数在达到MaxClients的设值后不再增加，但此时访问网站也很流畅，那就不用贪心再设置更高的值了，不然以后如果网站访问突增不小心就会耗光服务器内存，可根据以后访问压力趋势及内存的占用变化再逐渐调整，直到找到一个最优的设置值。<br/><br/>(MaxRequestsPerChild不能设置为0，可能会因内存泄露导致服务器崩溃）<br/><br/>更佳最大值计算的公式：<br/><br/>apache_max_process_with_good_perfermance < (total_hardware_memory / apache_memory_per_process ) * 2<br/>apache_max_process = apache_max_process_with_good_perfermance * 1.5<br/><br/>附：<br/><br/>实时检测HTTPD连接数：<br/>watch -n 1 -d "pgrep httpd&#124;wc -l"<br/><br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=apache" rel="tag">apache</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?596</link>
<title><![CDATA[FreeBSD更改csh为bash产生错误的解决办法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Fri, 30 Dec 2011 06:10:51 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?596</guid> 
<description>
<![CDATA[ 
	操作系统：freebsd 8.0-RELEASE<br/>接触freebsd一天，感觉很不习惯 想把shell改为熟悉的bash<br/>步骤<br/>#cd /usr/ports/shells/bash<br/># make install clean ##这条命令忘记执行了 结果直接执行了下面的命令<br/>#chsh -s /usr/local/bin/bash<br/>于是杯具出现了 重新登录错误<br/> <br/>su:/usr/local/bin/bash: no such file or directory<br/>可见粗心大意 害人不浅<br/>解决办法：<br/>重启进入单用户模式 #启动时选择4<br/>因为硬重启 所以开始先检测磁盘<br/>#fsck<br/>#mount -a <br/>#chpass -s /bin/csh <br/>重启正常登录 执行<br/># make install clean <br/> <br/>#vim /etc/profile<br/>在里面加入下面命令(这里根据自己情况修改 如果PS1变量正常 不需要改动)<br/> PS1="`whoami`@`hostname &#124; sed 's/&#92;..*//'`"<br/> case `id -u` in<br/> &nbsp; &nbsp; &nbsp; &nbsp;0) PS1="${PS1}# ";;<br/> &nbsp; &nbsp; &nbsp; &nbsp;*) PS1="${PS1}$ ";;<br/> esac<br/>注销重新登录即可<br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=csh" rel="tag">csh</a> , <a href="tag.php?tag=bash" rel="tag">bash</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?593</link>
<title><![CDATA[freebsd下使用的SSH命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 10 Oct 2011 06:51:30 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?593</guid> 
<description>
<![CDATA[ 
	ssh -l 用户名 -p 端口 hostip<br/>执行后，输入密码就可以连接到其他的服务器了。<br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=ssh" rel="tag">ssh</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?563</link>
<title><![CDATA[肖飞：盗链图片显示我们的广告]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Tue, 13 Jul 2010 04:32:53 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?563</guid> 
<description>
<![CDATA[ 
	如果别人盗链我们的图片，我们就让他们显示我们的广告。呵呵！<br/>在httpd.conf 加入下面的语句。<br/><IfModule mod_rewrite.c><br/>RewriteEngine On<br/>RewriteCond %{HTTP_REFERER} !^http://www.5217U.com/.*$ [NC]<br/>RewriteCond %{HTTP_REFERER} !^http://www.5217U.com$ [NC]<br/>RewriteRule .*&#92;.(gif&#124;jpg&#124;png)$http://www.5217U.com/404.jpg[R,NC]<br/></IfModule><br/><br/>这样就大功告成了。肖飞倾情奉献！<br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=apache" rel="tag">apache</a> , <a href="tag.php?tag=%E9%98%B2%E7%9B%97%E9%93%BE" rel="tag">防盗链</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?560</link>
<title><![CDATA[linux/freebsd查看目录下文件大小的命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Thu, 01 Jul 2010 10:12:34 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?560</guid> 
<description>
<![CDATA[ 
	linux/freebsd查看目录大小的命令<br/>freebsd的命令:<br/>在某个目录里执行 du -h -d 1 可以查看目录里的每个子目录的大小<br/>df -h可以查看各mount点及磁盘空间的使用率!<br/>linux的命令:<br/>linux下则为: du -h --max-depth=1<br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=%E7%9B%AE%E5%BD%95" rel="tag">目录</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?559</link>
<title><![CDATA[FREEBSD 建目录上限]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Thu, 01 Jul 2010 09:05:56 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?559</guid> 
<description>
<![CDATA[ 
	FREEBSD 系统一般在I/O操作时,不只需要磁盘的空间 onodes也同样重要<br/><br/>onodes是根据磁盘空间自动设定的,也有办法调整<br/><br/>调整Inode数量<br/>另外，每个分区的Inode数目是有限的。<br/>可以使用df -i来查看<br/><br/># df -i<br/>Filesystem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Inodes &nbsp; IUsed &nbsp; IFree IUse% Mounted on<br/>/dev/mapper/VolGroup00-LogVol00<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1958400 &nbsp; 97435 1860965 &nbsp; &nbsp;5% /<br/>/dev/sda1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;26104 &nbsp; &nbsp; &nbsp;32 &nbsp; 26072 &nbsp; &nbsp;1% /boot<br/>/dev/shm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 23850 &nbsp; &nbsp; &nbsp; 1 &nbsp; 23849 &nbsp; &nbsp;1% /dev/shm<br/><br/>当一个磁盘分区（文件子系统）的Inode被用光的时候，是无法再创建文件的。<br/>这种情况在邮件服务器或者BBS这种系统中容易出现，因为用户创建了很多小文件的情况。<br/><br/>要增加Inode的数量只能umount文件系统，然后用newfs命令来调整<br/><br/>#newfs /dev/sda1 -i 调整字节/inode的比例，来达到增加创建inode数目的目的。<br/>磁盘空间一定的情况下，当然比例越小，能创建的Inode就越多<br/><br/>不过注意。调整Inode相当于重新格式化了分区。原有的文件都会丢失<br/>所以确实需要调整的话，先要备份数据；<br/>或者在服务器搭建时预先设置好。<br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=inode" rel="tag">inode</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?557</link>
<title><![CDATA[BSD的虚拟磁盘技术]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Thu, 17 Jun 2010 04:06:52 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?557</guid> 
<description>
<![CDATA[ 
	去掉开机自动加载虚拟磁盘并mount到/var,网上有资料说：<br/>It seems that you have set "varmfs=YES" in you /etc/rc.conf or /var is not popular writable<br/>然后按照下面的操作就可解决。<br/>vi /etc/rc.conf<br/>varmfs="NO" <br/>populate_var="NO"# mdconfig -a -t swap -s 30M <br/>这就会在虚拟内存中申请30M空间，并创建虚拟磁盘，使用的虚拟设备为第 一个md设备md0，如果系统中的md0设备已经被占用，那么mdconfig就依序向后寻找下一个空余的md设备，并创建它。由于mdconfig能自 动创建新的设备，这样就解决了在内核配置文件指定伪设备数量的问题。 <br/>也可以使用-u指定使用的md伪设备的序号，例如下列命令将创建md10，并使用它作为虚拟磁盘设备：<br/># mdconfig -a -t swap -s 30M -u 10 <br/>上面的命令都是使用虚拟内存空间作为数据存储空间，是由swap参数指定的。同样，使用mdconfig也能从内核空间中创建虚拟磁盘，此时-t指定的存储类型参数为malloc，这告诉内核使用内核的MALLOC方法申请内存。 <br/># mdconfig -a -t malloc -s 30M <br/>这种方法就相当于老的md设备的申请内存的方法，但显然更为灵活，因为可以在具体使用过程中申请内存和设备，这是因为FreeBSD 5.0的内核允许更灵活的使用MALLOC内存申请方式。当然，一般还是主要使用swap申请虚拟空间的内存。 <br/>由于mdconfig和伪设备md将完全代替vnconfig和伪设备vn，那么使用mdconfig也能创建使用文件作为虚拟磁盘的与vn兼容的方式，这需要指定存储类型参数为vnode，并使用　-f指定具体的存储数据的物理文件名字。 <br/># mdconfig -a -t vnode -f imagefile -s 30M <br/>在使用mdconfig配置好虚拟磁盘之后，就可以使用disklabel、newfs、mount等管理虚拟磁盘。而在不需要这些虚拟磁盘的时候，就可以卸载相应的文件系统，并使用mdconfig删除指定的磁盘等。 <br/># mdconfig -l <br/>使用参数”-l”，则mdconfig列出系统中所有的虚拟磁盘设备。 <br/># mdconfig -d -u 0 <br/>为了删除指定了磁盘，需要使用”-d"参数，而使用"-u 0”则指定删除序号为0的虚拟磁盘，即md0。<br/>Tags - <a href="tag.php?tag=%E8%99%9A%E6%8B%9F%E7%A3%81%E7%9B%98%E6%8A%80%E6%9C%AF" rel="tag">虚拟磁盘技术</a> , <a href="tag.php?tag=freebsd" rel="tag">freebsd</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?556</link>
<title><![CDATA[转freebsd+nginx+php+mysql+zend+phpmyadmin+系统优化+防止ddos +傻瓜式ports安装法 ]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 09 Jun 2010 06:24:49 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?556</guid> 
<description>
<![CDATA[ 
	 看了张宴的《linux版本的Nginx 0.5.33 + PHP 5.2.5》后，马上找了一台服务器测试了一下，然后加了一个线上的discuz的论坛跑了一下，性能非常的卓越，感叹搜遍整个互联网，就是nginx+php唯一的一篇文档。对于他的文档，我认为：写的非常专业，对于php extensions库也分析的非常透彻。但是一篇专业的文档，也存在一些专业带来的麻烦，就是起点有点高，假如要更新里面的软件包和定义自己的目录，势必需要一点波折。另外不知道为何，最近网站老是打不开。情急之下，小弟重新写了一篇freebsd下面的傻瓜式安装文档。<br/>2. 又结合了平时的一些经验，顺便把如何防卸ddos，并通过对系统的优化，如何来进一步提高nginx的并发数做 一些详解。<br/>3. 由于个人能力有限，错误的地方，还请读者谅解<br/><br/>一、安装软件前的准备<br/>系统的安装：插入freebsd6.2以上的光盘，最小化安装系统，同时安装好ports<br/>二、手动安装nginx+php<br/>1) 进入系统后，准备cvs更新：<br/>1. cd /usr/ports/net/cvsup-without-gui<br/>2. cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile<br/>3. # vi /etc/ports-supfile<br/>将其中的#*default host=CHANGE_THIS.FreeBSD.org一行改为<br/>*default host=cvsup4.FreeBSDchina.org<br/>4. 更新ports<br/>/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile<br/>2) 安装mysql<br/>#cd /usr/ports/databases/mysql51-server<br/>#make thread-safe-client=enable dtrace=disable assembler=enable with_big_tables=yes with_embedded_server=yes with_local_infile=yes with_plugins=partition,innobase,myisammrg WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_general_ci WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes install clean<br/>#cp /usr/local/share/mysql/my-large.cnf /usr/local/etc/my.cnf ##mysql的优化参数，也可以手动修改<br/>#rehash<br/># mysql_install_db –user=mysql ##初始化mysql<br/>#/usr/local/bin/mysqld_safe & ##启动mysql<br/>#/usr/local/bin/mysqladmin -u root password ‘newpass’ ##修改root密码，newpass是你需要改的密码<br/>关闭mysql可以使用mysqladmin -uroot -p shutdown<br/>3) 安装php<br/>#cd /usr/ports/lang/php5<br/>#make config ##配置编译参数<br/>[X] CLI Build CLI version<br/>[X] CGI Build CGI version<br/>[ ] APACHE Build Apache module<br/>[ ] DEBUG Enable debug<br/>[X]] SUHOSIN Enable Suhosin protection system<br/>[X] MULTIBYTE Enable zend multibyte support<br/>[ ] IPV6 Enable ipv6 support<br/>[ ] REDIRECT Enable force-cgi-redirect support (CGI only)<br/>[ ] DISCARD Enable discard-path support (CGI only)<br/>[X] FASTCGI Enable fastcgi support (CGI only)<br/>[X] PATHINFO Enable path-info-check support (CGI only)<br/>#make install clean<br/># cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini ##cp php.ini配置文件<br/>4) 安装php5-extensions<br/># cd /usr/ports/lang/php5-extensions/<br/>#make config<br/>Options for php5-extensions 1.1<br/>————————————————-<br/>[X] CURL CURL support<br/>[X] FTP FTP support<br/>[X] GD<br/>[X] GETTEXT<br/>[X] MBSTRING multibyte string support<br/>[X] MCRYPT Encryption support<br/>[X] MYSQL<br/>[X] PCRE Perl Compatible Regular Expression support<br/>[ ] POSIX //去掉.<br/>[ ] SQLITE //去掉.<br/>[X] ZIP ZIP support<br/>[X] ZLIB<br/># make install clean<br/>5) 安装Zend Optimizer<br/>#cd /usr/ports/devel/ZendOptimizer/<br/>#make #不要安装，只需要下载解包<br/>#cd /usr/ports/devel/ZendOptimizer/work/ZendOptimizer-*<br/>#./install-tty ##会出现一个文字的安装界面，只是最后一步，不要选择apache就可以了<br/>#vi /usr/local/etc/php.ini #插入zend的路径，一般来说，上面的安装会自动加入下面的文字，假如没有，请手动添加。<br/><br/>[Zend]<br/>zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0<br/>zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0<br/>zend_optimizer.version=3.3.0a<br/>zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so<br/>zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so<br/><br/>小提示：安装zend，在freebsd下面，目前只有支持到 php5.1.x，对于php5.2.x还不能支持，因为zend还没有为php5.2.x开发版本，在网上查了好多关于解决此类的问题，但得到的结果是，zend可以顺利安装，phpinfo也显示zend正常了，但程序无法调用，即zend没有工作，也就是目前无法解决，我想只有等到zend php5.2.x的版本后，才可以解决此问题，也希望哪位已经解决此类问题的兄弟，share一下你的经验。假如你非要使用zend，那就请你将php降到5.1.x，或者你不当心已经升级了ports，那建议你可以安装php4.x，毕竟目前php4.x还通用于大部分的环境<br/>6) 安装nginx<br/>#cd /usr/ports/www/nginx/<br/>#make install<br/>7) 安装lighttpd，为了得到fastcgi<br/># cd /usr/ports/www/lighttpd/<br/>#make install<br/>#rehash<br/> 配置nginx<br/>#user nobody<br/>删除前面的注释#，改成 user www<br/>#log_format main ‘$remote_addr – $remote_user [$time_local] ‘<br/># ‘”$request” $status $body_bytes_sent ‘<br/># ‘”$http_referer” “$http_user_agent”‘;<br/>log_format main ‘$remote_addr – $remote_user [$time_local] ‘<br/>‘”$request” $status $body_bytes_sent ‘<br/>‘”$http_referer” “$http_user_agent”‘;<br/>##以上步骤，为了能够正常分析log的pv，hits，访问量，才设定的，默认的log格式，是无法准确分析出所需要的结果<br/><br/>location / {<br/>root /usr/local/www/nginx;<br/>index index.html index.htm;<br/>}<br/>在index.html前面添加一个index.php<br/>location / {<br/>root /data/web/www.jk0086.com/htdocs;<br/>index index.php index.html index.htm;<br/>}<br/>#location ~ &#92;.php$ {<br/># fastcgi_pass 127.0.0.1:9000;<br/># fastcgi_index index.php;<br/># fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script.name;<br/># include fastcgi_params;<br/>#}<br/>将前面的#去掉，修改为<br/>location ~ &#92;.php$ {<br/>fastcgi_pass 127.0.0.1:9000;<br/>fastcgi_index index.php;<br/>fastcgi_param SCRIPT_FILENAME /usr/local/etc/nginx$fastcgi_script.name;<br/>include fastcgi_params;<br/>}<br/>##去掉注释，其实就是激活了nginx的fastcgi功能，也说明了nginx本身就已经准备用于fastcgi的环境中<br/><br/>9) 配置spawn-fcgi，就是一个启动fastcgi命令，使得nginx可以通过9000端口访问（纯粹个人理解-_-）<br/>参数说明：监听127.0.0.1的9000端口，进程数为64（如果服务器内存小于3GB，可以只开启25个进程），用户为www<br/>/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 64 -f /usr/local/bin/php-cgi<br/>10) 这边请注意启动顺序，先启动fastcgi，再启动nginx<br/>Nginx.conf由于经常需要修改，即经常需要重启nginx，因此这边写了一个启动脚本，请查看：<br/>#!/usr/local/bin/bash<br/>case $1 in<br/>start)<br/>/usr/local/sbin/nginx<br/>;;<br/>stop)<br/>killall -9 nginx<br/>;;<br/>test)<br/>nginx -t -c /usr/local/etc/nginx/nginx.conf<br/>;;<br/>restart)<br/>ps auxww &#124; grep nginx &#124; grep master &#124; awk ‘{print $2}’ &#124; xargs kill -HUP<br/>;;<br/>show)<br/>ps -aux&#124;grep nginx<br/>;;<br/>esac<br/>保存为nginx.sh使用方法为：<br/>nginx.sh start #启动nginx<br/>nginx.sh stop #停止nginx<br/>nginx.sh restart #重启nginx<br/>nginx.sh test #测试nginx.conf的准确性<br/>11) 安装phpMyAdmin<br/>#cd /usr/ports/databases/phpmyadmin<br/>#make install<br/>#mv /usr/local/www/phpmyadmin /data/web/ www.jk0086.com/htdocs/<br/>#cd /data/web/www.jk0086.com/htdocs/phpmyadmin<br/>#vi config.inc.php ##这边要说明一下，freebsd默认安装的phpmyadmin，里面配置文件有问题，需要手动修改，请修改成如下内容：<br/><br/>/* $Id: config.sample.inc.php 9689 2006-11-10 20:05:49Z nijel $ */<br/><br/>// vim: expandtab sw=4 ts=4 sts=4:<br/><br/>/**<br/><br/>* phpMyAdmin sample configuration, you can use it as base for<br/><br/>* manual configuration. For easier setup you can use scripts/setup.php<br/><br/>*<br/><br/>* All directives are explained in Documentation.html and on phpMyAdmin<br/><br/>* wiki .<br/><br/>*/<br/><br/>/*<br/><br/>* This is needed for cookie based authentication to encrypt password in<br/><br/>* cookie<br/><br/>*/<br/><br/>$cfg['blowfish_secret'] = ‘asdf:LKJ’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */<br/><br/>/*<br/><br/>* Servers configuration<br/><br/>*/<br/><br/>$i = 0;<br/><br/>/*<br/><br/>* First server<br/><br/>*/<br/><br/>$i++;<br/><br/>/* Authentication type */<br/><br/>$cfg['Servers'][$i]['auth_type'] = ‘cookie’;<br/><br/>/* Server parameters */<br/><br/>$cfg['Servers'][$i]['host'] = ‘localhost’;<br/><br/>$cfg['Servers'][$i]['connect_type'] = ‘tcp’;<br/><br/>$cfg['Servers'][$i]['compress'] = false;<br/><br/>/* Select mysqli if your server has it */<br/><br/>$cfg['Servers'][$i]['extension'] = ‘mysql’;<br/><br/>/* User for advanced features */<br/><br/>// $cfg['Servers'][$i]['controluser'] = ‘pam’;<br/><br/>// $cfg['Servers'][$i]['controlpass'] = ‘pampasswd’;<br/><br/>/* Advanced phpMyAdmin features */<br/><br/>// $cfg['Servers'][$i]['pmadb'] = ‘phpmyadmin’;<br/><br/>// $cfg['Servers'][$i]['bookmarktable'] = ‘pma_bookmark’;<br/><br/>// $cfg['Servers'][$i]['relation'] = ‘pma_relation’;<br/><br/>// $cfg['Servers'][$i]['table_info'] = ‘pma_table_info’;<br/><br/>// $cfg['Servers'][$i]['table_coords'] = ‘pma_table_coords’;<br/><br/>// $cfg['Servers'][$i]['pdf_pages'] = ‘pma_pdf_pages’;<br/><br/>// $cfg['Servers'][$i]['column_info'] = ‘pma_column_info’;<br/><br/>// $cfg['Servers'][$i]['history'] = ‘pma_history’;<br/><br/>// $cfg['Servers'][$i]['designer_coords'] = ‘pma_designer_coords’;<br/><br/>/*<br/><br/>* End of servers configuration<br/><br/>*/<br/><br/>/*<br/><br/>* Directories for saving/loading files from server<br/><br/>*/<br/><br/>$cfg['UploadDir'] = ”;<br/><br/>$cfg['SaveDir'] = ”;<br/><br/>?><br/><br/>以上只是一个配置文件，当你打开Phpmyadmin的时候，会提示你输入用户名密码，然后登陆数据库，相对比较安全的<br/><br/>三、系统优化+防止ddos<br/>1) 这个话题有点大，我相信我做的只是其中很小的一部分，同时很多人也会问我，是不是要编译内核，这边的回答是不需要编译任何内核，只需要copy文件，然后重启一下服务器就可以了。<br/>2) 加载文件修改<br/># vi /boot/loader.conf #加入如下文本<br/>kern.dfldsiz=”2147483648″ # Set the initial data size limit<br/>kern.maxdsiz=”2147483648″ # Set the max data size<br/>kern.ipc.nmbclusters=”0″ # Set the number of mbuf clusters<br/>kern.ipc.nsfbufs=”66560″ # Set the number of sendfile(2) bufs<br/>##解释：<br/>a． 第一，第二行主要是为了突破1G内存设置的<br/>b． 第三行其实是bsd的一个bug，当系统并发达到一个数量级的时候，系统会crash，这个是非常糟糕的事情，所幸更改了这个参数后，在高并发的时候，基本可以没有类似情况，当然非常bt的情况，还得进一步想办法<br/>c． 第四行是读取的文件数，如果你下载的文件比较大，且比较多，加大这个参数，是非常爽的<br/><br/>3) Sysctl修改<br/>#vi /etc/rc.local<br/>sysctl kern.ipc.maxsockets=100000 ##增加并发的socket，对于ddos很有用<br/>sysctl kern.ipc.somaxconn=65535 ##打开文件数<br/>sysctl net.inet.tcp.msl=2500 ##timeout时间<br/><br/>4) 通过上述的简单优化，会给你带来意外的惊喜，如果有兴趣的兄弟，可以尝试一下看看，绝无副作用。<br/><br/>四、其他<br/>1) 加速ports安装<br/>#vi /etc/make.conf ##加入如下<br/>MASTER_SITE_OVERRIDE?=http://ports.hshh.org/${DIST_SUBDIR}/<br/>MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/><br/>2) Freebsd颜色显示<br/>secureCRT设置:仿真:终端->linux>勾选ANSI颜色–>确定<br/>#vi /etc/csh.cshrc ##加入如下<br/>setenv LSCOLORS ExGxFxdxCxegedabagExEx<br/>setenv CLICOLOR yes<br/>#cd /usr/ports/edit/vim;make install<br/>#echo “syntax on”>/root/.vimrc<br/>#echo “alias vi vim” >>/root/.cshrc<br/>##颜色主要是靠vim来显示的，因此需要安装vim，然后把vi alias成vim就可以了<br/>3) Other。。。。。。。。更新中<br/><br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=nginx" rel="tag">nginx</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?535</link>
<title><![CDATA[php无法加载pcre.so的解决办法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Fri, 09 Apr 2010 03:41:25 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?535</guid> 
<description>
<![CDATA[ 
	最近在帮朋友更新一台服务器，把apache和php全部重新安装。<br/>首先使用在ports中将apache和php5，及php5-extension都deinstall了。不过有些地方还是卸载的不干净。<br/>甚至有很多关联软件都卸载不了。只能使用pkg_delete -f来删除了。<br/><br/>删除过程就不多讲了。现在删掉了以后，重新安装apache和php5和php5-extension都挺顺利的，可是调用phpinfo时，却总是缺少了pcre这么模块。<br/>查看了extension.ini确实有加载pcre.so，重启apache还是没看到pcre这个模块。<br/>重装该模块，确定了配置文件中都有加载指令了，重启apache还是没有加载pcre模块。<br/>比较诡异了，去把pcre.so删掉，再重装，重启后还是没看到加载pcre模块。<br/>感觉快无计可施了。静下心来想想，也许是老的安装包保留下来了，才会这样的。<br/>所以执行了make reinstall FORCE_PKG_REGISTER="yes" clean<br/>加上了clean指令，以前没加的。这次安装还是不行，但是把老安装包给清掉了。<br/>再次执行make reinstall FORCE_PKG_REGISTER="yes" clean<br/>这次就安装成功了。说明问题是之前安装的模块是老的安装包，freebsd检查有老的安装包以后就不重新下载了，直接安装，所以总是有问题。这次把老安装包清除之后，再安装，从网上下载了新的安装包，一次就成功了。<br/><br/>本文由ArthurXF倾情奉献，希望对大家有所帮助！<br/>Tags - <a href="tag.php?tag=php" rel="tag">php</a> , <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=pcre" rel="tag">pcre</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?534</link>
<title><![CDATA[解决Character set gb2312 is not a compiled character set and is not specified in the /usr/local/share/mysql/charsets/Index.xml file]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Tue, 06 Apr 2010 07:36:04 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?534</guid> 
<description>
<![CDATA[ 
	今天在给新版的5117.com网站配置新服务器。结果msyql安装好了以后在命令行就是无法进入mysql。总是报错Character set 'gb2312' is not a compiled character set and is not specified in the '/usr/local/share/mysql/charsets/Index.xml' file<br/><br/>我也到这个Index.xml中把关于gb2312的内容全部注释掉了，也没好。重装了mysql特意加上了支持utf-8参数，也没用。到my.conf中加上了default-character-set=utf8也不行。<br/>最后想到我的环境变量中配置了中文环境，也许是那里的问题。<br/>就<br/>cd /root<br/>ee .cshrc<br/>加注释<br/>#setenv LC_ALL zh_CN.eucCN<br/>#setenv LANG &nbsp;zh_CN.eucCN<br/>#setenv LC_CTYPE zh_CN.eucCN<br/>保存重启。一切回复正常。<br/>所以碰到问题，不一定就是mysql的问题，也不是它提示出来的错误。<br/>本文由ArthurXF倾情奉献，转载请注明网址。<br/>Tags - <a href="tag.php?tag=mysql" rel="tag">mysql</a> , <a href="tag.php?tag=charset" rel="tag">charset</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?518</link>
<title><![CDATA[apache启用.htaccess需要的设置]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Fri, 20 Nov 2009 02:41:28 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?518</guid> 
<description>
<![CDATA[ 
	如何让自己的本地Apache服务器支持".htaccess"呢?其实只要简单修改一下apache的httpd.conf设置就可以让APACHE支持.htaccess了。打开httpd.conf文件(在那里? APACHE目录的CONF目录里面),用文本编辑器打开后,查找 <br/><br/><Directory /><br/>Options FollowSymLinks<br/>AllowOverride None<br/></Directory><br/>改为 <br/><br/><Directory /><br/>Options FollowSymLinks<br/>AllowOverride All<br/></Directory><br/>就可以了 <br/><br/>RewriteEngine On&#124;Off 如果存在.htaccess的文件，应当显式地指明RewriteEngine On. 因为默认情况下.htaccess的RewriteEngine项是Off的。因此如果想用.htaccess来设置rewrite,文件头一行一般都需要RewriteEngine On<br/>Tags - <a href="tag.php?tag=apache" rel="tag">apache</a> , <a href="tag.php?tag=.htaccess" rel="tag">.htaccess</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?517</link>
<title><![CDATA[最快的 Web 服务器软件Cherokee ]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 04 Nov 2009 03:22:16 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?517</guid> 
<description>
<![CDATA[ 
	Cherokee 号称是目前最快的 Web 服务器软件，在性能上，甚至比 Nginx 还略胜一筹。与 Apache、Lighttpd、Nginx 等其他同类软件的对比，大家不妨看看这个测试页面。其易用性做得也很不错。<br/><br/>Cherokee 的功能包括支持 FastCGI、SCGI、PHP、CGI、TLS 及 SSL 加密连接，虚拟主机，授权认证，实时编码，载入均衡，与 Apache 兼容的 log 文件等等。<br/><br/>Cherokee 内含一个名为 cherokee-admin 的工具，执行后，允许管理员直接通过浏览器进入 http://localhost:9090/ 对其进行管理和配置。比如，开启或关闭服务器，进行一般选项的设定，配置虚拟服务器、信息源、图标、Mime 类型等项目。<br/><br/><a href="http://www.cherokee-project.com/ " target="_blank">http://www.cherokee-project.com/ </a><br/>Tags - <a href="tag.php?tag=web" rel="tag">web</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?513</link>
<title><![CDATA[make deinstall后不能install的解决办法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Tue, 15 Sep 2009 16:48:39 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?513</guid> 
<description>
<![CDATA[ 
	如果你碰到make deinstall后，再make install时报错，说已经安装过了，可以使用以下办法来解决。<br/>setenv FORCE_PKG_REGISTER<br/>后在用make install，就会强制安装了。<br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=deinstall" rel="tag">deinstall</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?512</link>
<title><![CDATA[Apache错误:child pid 6880 exit signal Segmentation fault (11)的解决办法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 14 Sep 2009 14:59:06 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?512</guid> 
<description>
<![CDATA[ 
	　　最近配置了一台新服务器，网站流量一大，就会出现类似child pid 6880 exit signal Segmentation fault (11)的错误，产生的原因是新旧版本的程序更新模块更新问题，建议彻底卸载apache和php进行重新安装，即可修复。<br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=apache" rel="tag">apache</a> , <a href="tag.php?tag=%E9%94%99%E8%AF%AF" rel="tag">错误</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?509</link>
<title><![CDATA[Apache的prefork模式和worker模式的比较]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 24 Aug 2009 16:22:35 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?509</guid> 
<description>
<![CDATA[ 
	prefork模式<br/>这个多路处理模块(MPM)实现了一个非线程型的、预派生的web服务器，它的工作方式类似于Apache 1.3。它适合于没有线程安全库，需要避免线程兼容性问题的系统。它是要求将每个请求相互独立的情况下最好的MPM，这样若一个请求出现问题就不会影响到其他请求。<br/><br/>这个MPM具有很强的自我调节能力，只需要很少的配置指令调整。最重要的是将MaxClients设置为一个足够大的数值以处理潜在的请求高峰，同时又不能太大，以致需要使用的内存超出物理内存的大小。<br/><br/>worker模式<br/>此多路处理模块(MPM)使网络服务器支持混合的多线程多进程。由于使用线程来处理请求，所以可以处理海量请求，而系统资源的开销小于基于进程的MPM。但是，它也使用了多进程，每个进程又有多个线程，以获得基于进程的MPM的稳定性。<br/><br/>控制这个MPM的最重要的指令是，控制每个子进程允许建立的线程数的ThreadsPerChild指令，和控制允许建立的总线程数的MaxClients指令。<br/><br/><br/>prefork和worker模式的切换<br/>1.将当前的prefork模式启动文件改名<br/>mv httpd httpd.prefork<br/>2.将worker模式的启动文件改名<br/>mv httpd.worker httpd<br/>3.修改Apache配置文件<br/>vi /usr/local/apache2/conf/extra/httpd-mpm.conf<br/>找到里边的如下一段，可适当修改负载等参数：<br/><IfModule mpm_worker_module><br/>StartServers 2<br/>MaxClients 150<br/>MinSpareThreads 25<br/>MaxSpareThreads 75<br/>ThreadsPerChild 25<br/>MaxRequestsPerChild 0<br/></IfModule><br/>4.重新启动服务<br/>/usr/local/apache2/bin/apachectl restart<br/>即可换成worker方式启动apache2<br/><br/>处于稳定性和安全性考虑，不建议更换apache2的运行方式，使用系统默认prefork即可。另外很多php模块不能工作在worker模式下，例如redhat linux自带的php也不能支持线程安全。所以最好不要切换工作模式。<br/><br/>prefork和worker模式的比较<br/>prefork模式使用多个子进程，每个子进程只有一个线程。每个进程在某个确定的时间只能维持一个连接。在大多数平台上，Prefork MPM在效率上要比Worker MPM要高，但是内存使用大得多。prefork的无线程设计在某些情况下将比worker更有优势：它可以使用那些没有处理好线程安全的第三方模块，并且对于那些线程调试困难的平台而言，它也更容易调试一些。<br/><br/>worker模式使用多个子进程，每个子进程有多个线程。每个线程在某个确定的时间只能维持一个连接。通常来说，在一个高流量的HTTP服务器上，Worker MPM是个比较好的选择，因为Worker MPM的内存使用比Prefork MPM要低得多。但worker MPM也由不完善的地方，如果一个线程崩溃，整个进程就会连同其所有线程一起”死掉”.由于线程共享内存空间，所以一个程序在运行时必须被系统识别为”每个线程都是安全的”。<br/><br/>总的来说，prefork方式速度要稍高于worker，然而它需要的cpu和memory资源也稍多于woker。<br/><br/>prefork模式配置详解<br/><IfModule mpm_prefork_module><br/>ServerLimit 256<br/>StartServers 5<br/>MinSpareServers 5<br/>MaxSpareServers 10<br/>MaxClients 256<br/>MaxRequestsPerChild 0<br/></IfModule><br/>ServerLimit<br/>默认的MaxClient最大是256个线程,如果想设置更大的值，就的加上ServerLimit这个参数。20000是ServerLimit这个参数的最大值。如果需要更大，则必须编译apache,此前都是不需要重新编译Apache。<br/>生效前提：必须放在其他指令的前面<br/><br/>StartServers<br/>指定服务器启动时建立的子进程数量，prefork默认为5。<br/><br/>MinSpareServers<br/>指定空闲子进程的最小数量，默认为5。如果当前空闲子进程数少于MinSpareServers ，那么Apache将以最大每秒一个的速度产生新的子进程。此参数不要设的太大。<br/><br/>MaxSpareServers<br/>设置空闲子进程的最大数量，默认为10。如果当前有超过MaxSpareServers数量的空闲子进程，那么父进程将杀死多余的子进程。此参数不要设的太大。如果你将该指令的值设置为比MinSpareServers小，Apache将会自动将其修改成”MinSpareServers+1″。<br/><br/>MaxClients<br/>限定同一时间客户端最大接入请求的数量(单个进程并发线程数)，默认为256。任何超过MaxClients限制的请求都将进入等候队列,一旦一个链接被释放，队列中的请求将得到服务。要增大这个值，你必须同时增大ServerLimit。<br/><br/>MaxRequestsPerChild<br/>每个子进程在其生存期内允许伺服的最大请求数量，默认为10000.到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为”0″，子进程将永远不会结束。将MaxRequestsPerChild设置成非零值有两个好处：<br/>1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。<br/>2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。<br/><br/>worker模式配置详解<br/><IfModule mpm_worker_module><br/>StartServers 2<br/>MaxClients 150<br/>MinSpareThreads 25<br/>MaxSpareThreads 75<br/>ThreadsPerChild 25<br/>MaxRequestsPerChild 0<br/></IfModule><br/><br/>StartServers<br/>服务器启动时建立的子进程数，默认值是”3″。<br/><br/>MaxClients<br/>允许同时伺服的最大接入请求数量(最大线程数量)。任何超过MaxClients限制的请求都将进入等候队列。默认值是”400″,16(ServerLimit)乘以25(ThreadsPerChild)的结果。因此要增加MaxClients的时候，你必须同时增加ServerLimit的值。<br/><br/>MinSpareThreads<br/>最小空闲线程数,默认值是”75″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太少，子进程将产生新的空闲线程。<br/><br/>MaxSpareThreads<br/>设置最大空闲线程数。默认值是”250″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太多，子进程将杀死多余的空闲线程。MaxSpareThreads的取值范围是有限制的。Apache将按照如下限制自动修正你设置的值：worker要求其大于等于MinSpareThreads加上ThreadsPerChild的和。<br/><br/>ThreadsPerChild<br/>每个子进程建立的常驻的执行线程数。默认值是25。子进程在启动时建立这些线程后就不再建立新的线程了。<br/><br/>MaxRequestsPerChild<br/>设置每个子进程在其生存期内允许伺服的最大请求数量。到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为”0″，子进程将永远不会结束。将MaxRequestsPerChild设置成非零值有两个好处：<br/>1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。<br/>2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。<br/>注意对于KeepAlive链接，只有第一个请求会被计数。事实上，它改变了每个子进程限制最大链接数量的行为。<br/><br/><br/>选择prefork还是worker可以在编译时使用–with-mpm=MPM参数指定,默认为prefork,preforkprefork采用预派生子进程方式，用单独的子进程来处理 不同的请求，进程之间彼此独立。在make编译和make install安装后，使用httpd -l来确定当前使用的MPM是prefork.c。查看httpd-mpm.conf配置文件，里面包含如下默认的配置段：<br/><IfModule prefork.c><br/>StartServers 5<br/>MinSpareServers 5<br/>MaxSpareServers 10<br/>MaxClients 150<br/>MaxRequestsPerChild 0<br/></IfModule><br/><br/>prefork 控制进程在最初建立“StartServers”个子进程后，为了满足MinSpareServers设置的需要创建一个进程，等待一秒钟，继续创建两 个，再等待一秒钟，继续创建四个……如此按指数级增加创建的进程数，最多达到每秒32个，直到满足MinSpareServers设置的值为止。这种模式 可以不必在请求到来时再产生新的进程，从而减小了系统开销以增加性能。MaxSpareServers设置了最大的空闲进程数，如果空闲进程数大于这个 值，Apache会自动kill掉一些多余进程。这个值不要设得过大，但如果设的值比MinSpareServers小，Apache会自动把其调整为 MinSpareServers+1。如果站点负载较大，可考虑同时加大MinSpareServers和MaxSpareServers。 MaxRequestsPerChild设置的是每个子进程可处理的请求数。每个子进程在处理了“MaxRequestsPerChild”个请求后将自 动销毁。0意味着无限，即子进程永不销毁。虽然缺省设为0可以使每个子进程处理更多的请求，但如果设成非零值也有两点重要的好处：1、可防止意外的内存泄 漏。2、在服务器负载下降的时侯会自动减少子进程数。因此，可根据服务器的负载来调整这个值。MaxClients是这些指令中最为重要的一个，设定的是 Apache可以同时处理的请求，是对Apache性能影响最大的参数。其缺省值150是远远不够的，如果请求总数已达到这个值（可通过ps -ef&#124;grep http&#124;wc -l来确认），那么后面的请求就要排队，直到某个已处理请求完毕。这就是系统资源还剩下很多而HTTP访问却很慢的主要原因。虽然理论上这个值越大，可以 处理的请求就越多，但Apache默认的限制不能大于256。ServerLimit指令无须重编译Apache就可以加大MaxClients。<br/><IfModule prefork.c><br/>ServerLimit 10000<br/>StartServers 5<br/>MinSpareServers 5<br/>MaxSpareServers 10<br/>MaxClients 10000<br/>MaxRequestsPerChild 0<br/></IfModule><br/>Worker相对于prefork，worker全新的支持多线程和多进程混合模型的MPM。由于 使用线程来处理，所以可以处理相对海量的请求，而系统资源的开销要小于基于进程的服务器。但是，worker也使用了多进程，每个进程又生成多个线程，以 获得基于进程服务器的稳定性。在configure –with-mpm=worker后，进行make编译、make install安装。在缺省生成的httpd-mpm.conf中有以下默认配置段：<br/><IfModule worker.c><br/>StartServers 2<br/>MaxClients 150<br/>MinSpareThreads 25<br/>MaxSpareThreads 75<br/>ThreadsPerChild 25<br/>MaxRequestsPerChild 0<br/></IfModule><br/>Worker 由主控制进程生成“StartServers”个子进程，每个子进程中包含固定的ThreadsPerChild线程数，各个线程独立地处理请求。同样， 为了不在请求到来时再生成线程，MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数；而MaxClients 设置了同时连入的clients最大总数。如果现有子进程中的线程总数不能满足负载，控制进程将派生新的子进程。MinSpareThreads和 MaxSpareThreads的最大缺省值分别是75和250。这两个参数对Apache的性能影响并不大，可以按照实际情况相应调节。 ThreadsPerChild是worker MPM中与性能相关最密切的指令。ThreadsPerChild的最大缺省值是64，如果负载较大，64也是不够的。这时要显式使用 ThreadLimit指令，它的最大缺省值是20000。Worker模式下所能同时处理的请求总数是由子进程总数乘以ThreadsPerChild 值决定的，应该大于等于MaxClients。如果负载很大，现有的子进程数不能满足时，控制进程会派生新的子进程。默认最大的子进程总数是16，加大时 也需要显式声明ServerLimit（最大值是20000）。需要注意的是，如果显式声明了ServerLimit，那么它乘以 ThreadsPerChild的值必须大于等于MaxClients，而且MaxClients必须是ThreadsPerChild的整数倍，否则 Apache将会自动调节到一个相应值。<br/><IfModule worker.c><br/>ServerLimit 25<br/>ThreadLimit 200<br/>StartServers 3<br/>MaxClients 2000<br/>MinSpareThreads 50<br/>MaxSpareThreads 200<br/>ThreadsPerChild 100<br/>MaxRequestsPerChild 0<br/></IfModule><br/><br/>2.要加到多少？<br/><br/>连接数理论上当然是支持越大越好，但要在服务器的能力范围内，这跟服务器的CPU、内存、带宽等都有关系。<br/><br/>查看当前的连接数可以用：<br/>ps aux &#124; grep httpd &#124; wc -l<br/><br/>或：<br/>pgrep httpd&#124;wc -l<br/><br/>计算httpd占用内存的平均数:<br/>ps aux&#124;grep -v grep&#124;awk '/httpd/{sum+=$6;n++};END{print sum/n}'<br/><br/>由于基本都是静态页面，CPU消耗很低，每进程占用内存也不算多，大约200K。<br/><br/>服务器内存有2G，除去常规启动的服务大约需要500M（保守估计），还剩1.5G可用，那么理论上可以支持1.5*1024*1024*1024/200000 = 8053.06368<br/><br/>约8K个进程，支持2W人同时访问应该是没有问题的（能保证其中8K的人访问很快，其他的可能需要等待1、2秒才能连上，而一旦连上就会很流畅）<br/><br/><IfModule mpm_prefork_module><br/> &nbsp; &nbsp;ServerLimit &nbsp; &nbsp; &nbsp; &nbsp; 10000<br/> &nbsp; &nbsp;StartServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br/> &nbsp; &nbsp;MinSpareServers &nbsp; &nbsp; &nbsp; 10<br/> &nbsp; &nbsp;MaxSpareServers &nbsp; &nbsp; &nbsp;20<br/> &nbsp; &nbsp;MaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10000<br/> &nbsp; &nbsp;MaxRequestsPerChild &nbsp;100<br/></IfModule><br/>注意，MaxClients默认最大为250，若要超过这个值就要显式设置ServerLimit，且ServerLimit要放在MaxClients之前，值要不小于MaxClients，不然重启httpd时会有提示。<br/><br/>重启httpd后，通过反复执行pgrep httpd&#124;wc -l 来观察连接数，可以看到连接数在达到MaxClients的设值后不再增加，但此时访问网站也很流畅，那就不用贪心再设置更高的值了，不然以后如果网站访问突增不小心就会耗光服务器内存，可根据以后访问压力趋势及内存的占用变化再逐渐调整，直到找到一个最优的设置值。<br/><br/>(MaxRequestsPerChild不能设置为0，可能会因内存泄露导致服务器崩溃）<br/><br/>更佳最大值计算的公式：<br/><br/>apache_max_process_with_good_perfermance < (total_hardware_memory / apache_memory_per_process ) * 2<br/>apache_max_process = apache_max_process_with_good_perfermance * 1.5<br/><br/><br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=apache" rel="tag">apache</a> , <a href="tag.php?tag=prefork" rel="tag">prefork</a> , <a href="tag.php?tag=worker" rel="tag">worker</a>
]]>
</description>
</item>
</channel>
</rss>