Archive for 八月, 2010
安装mysql,在./configure时出现错误:error: No curses/termcap library found的解决办法
0在./configure后,make时出现以下错误:
make: *** No targets specified and no makefile found. stop.
在网上找到相关资料,确认是./configure出了问题,于是回头查看,果然发现问题:
最后几行出了错,完整错误信息如下:
checking for tgetent in -lncurses… no
checking for tgetent in -lcurses… no
checking for tgetent in -ltermcap… no
checking for tgetent in -ltinfo… no
checking for termcap functions library… configure: error: No curses/termcap library found
原因:
缺少ncurses安装包
解决办法:
下载安装相应软件包
一、如果你的系统是RedHat系列:
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
二、如果你的系统是Ubuntu或Debian:
apt-cache search ncurses
apt-get install libncurses5-dev
待安装completed!之后,再./configure,顺利通过,然后make && make install,成功安装,一切OK!~~~
禁用火狐浏览器的plugin-container.exe[zt]
0firefox版本3.6.6,我最近发现多了个plugin-container.exe,手动结束这个进程后,firefox的flash插件立马崩溃。这个进程的作用描述如下:
使某些plugin崩溃了也不影响firefox,不用重启fx,刷新下即可恢复正常。然而本功能比较占内存,不喜欢的可以禁用。
禁用方法:
输入about:config,会有一个“失去质保”的提示,确认继续。,(fileter:)plugins,以下是默认值,全部修改为false。
dom.ipc.plugins.enabled
dom.ipc.plugins.enabled.npctrl.dll
dom.ipc.plugins.enabled.npqtplugin.dll
dom.ipc.plugins.enabled.npswf32.dll
dom.ipc.plugins.enabled.nptest.dll
对于IFS的一点总结
0(1)什么是IFS ?
IFS是bash的内部变量,称为内部域分隔符.这个变量用来决定Bash在解释字符串时如何识别域,或者单词边界.
(2)如何查看当前的IFS值?
[root@Dong tmp]# echo "$IFS"
由于IFS默认为空白(空格,tab和新行),所以使用以上的命令似乎看不到字符。没关系,你可以用od命令看16进制,或是2进制值:
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004
注意:$*使用$IFS 中的第一个字符,比如:
[root@Dong tmp]# set w x y z;echo "$*"
w x y z
(3)如何修改IFS值?
普通的赋值命令即可:
[root@Dong tmp]# IFS=":"
[root@Dong tmp]# echo "$IFS"
:
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 3a 0a
0000002
[root@Dong tmp]# set w x y z;echo "$*"
w:x:y:z
(4)实验:$*使用$IFS 中的第一个字符
[root@Dong tmp]# IFS="\\:;"
[root@Dong tmp]# echo "$IFS"
\:;
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 5c 3a 3b 0a
0000004
[root@Dong tmp]# set w x y z;echo "$*"
w\x\y\z
[root@Dong tmp]# IFS=":;\\"
[root@Dong tmp]# echo "$IFS"
:;\
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 3a 3b 5c 0a
0000004
[root@Dong tmp]# set w x y z;echo "$*"
w:x:y:z
(5)备份IFS
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004
[root@Dong tmp]# OLDIFS="$IFS"
[root@Dong tmp]# echo "$OLDIFS" | od -t x1
0000000 20 09 0a 0a
0000004
[root@Dong tmp]# IFS=":"
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 3a 0a
0000002
[root@Dong tmp]# IFS="$OLDIFS"
[root@Dong tmp]# echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004
PHP判断奇偶数的函数[zt]
0因为PHP没有形成的判断奇偶函数,所以以前一直使用 %2 来判断一个数字变量是奇数还是偶数,如果把该变量 mod2 得到结果是1那么就是奇数,得到结果是 0 那么就是偶数。最近看了PHP手册,发现除了使用算术运算符判断,还可以使用位运算符来判断。
//判断奇数,是返回TRUE,否返回FALSE
function is_odd($num){
return (is_numeric($num)&($num&1));
}
//判断偶数,是返回TRUE,否返回FALSE
function is_even($num){
return (is_numeric($num)&(!($num&1)));
}
?>
当然,如果已经知道变量值是数字而非字符或字符串,则可以省略 is_numeric 函数的判断,直接使用 $num&1 来判断就行了。
各种工具之正则表达式语法比较[zt]
0在各种常用的工具中,
正则表达式如此的相似却又不同。
下表列出了一些常用的正则表达式,以及其不同之处。
项目总多,遗漏必有不少,请各位看官不吝指出。
以perl的正则为基准,不同的用法以粉红色标出。
| grep 2.5.1 | egrep 2.5.1 | sed 3.02 sed 4.07 |
awk 3.1.1 | perl 5.8.0 | vim 6.1 | JavaScript ?? | |
| 转义 | |||||||
| 行头 | ^ | ^ | ^ | ^ | ^ | ^ | ^ |
| 行尾 | $ | $ | $ | $ | $ | $ | $ |
| n个 {n} {m,n} {m,} {,n} | {n} | {n} | {n} | {n}或{n} 仅定义 –posix 或 –re-interval有效(要表达}和{,得用{和} 没有定义–posix或–re-interval时,不能用{n}的语法, }{和}{同义 | {n} | {n} | {n} |
| {0,} | * | * | * | *或*, (要表达*,得用*) | * | * | * |
| {1,} | + | + | + | +或+, (要表达+, 得用+) | + | + | + |
| {0,1} | ? | ? | ? | ?或?, (要表达?, 得用?) | ? | ? | ? |
| 任意字符 | . | . | . | . 含n. | . /s修饰后则含n | . 除n | . 除n |
| (pat) 匹配并获结果 | (pat) | (pat) | (pat) | (pat)或(pat) (要表达括号,用( ) ) | (pat) | (pat) | (pat) |
| (?:pat) 匹配但不获结果 | 不支持 | 不支持 | 不支持 | 不支持 | (?:pat) | 不支持 | (?:pat) |
| (?=pat) 等于预查 | 不支持 | 不支持 | 不支持 | 不支持 | (?=pat) | 不支持 | (?=pat) |
| (?!pat) 不等预查 | 不支持 | 不支持 | 不支持 | 不支持 | (?!pat) | 不支持 | (?!pat) |
| | 或 | | | | | | | |或| (要表达|,得用|) | | | | | | |
| 其中任意字符 | [xyz] | [xyz] | [xyz] | [xyz] | [xyz] | [xyz] | [xyz] |
| [.ch.] [=ch=] | 不支持 | 不支持 | [.ch.] | 不支持 | 不支持 | 不支持 | 不支持 |
| 单词边界 b | b | b | b | 不支持 | b | 不支持 | b |
| 非单词边界 B | B | B | B | 不支持 | B | 不支持 | B |
| 单词左右边界 <> | < > | < > | < > | 不支持 (><和><和><同义 | 不支持(><和><同义 | < > | 不支持(><和><同义 |
| 控制字符 /cx | 不支持 | 不支持 | cx | 不支持 | cx | 不支持 | cx |
| 数字d | 不支持 | 不支持 | 不支持 | 不支持 | d | d | d |
| 非数字D | 不支持 | 不支持 | 不支持 | 不支持 | D | D | D |
| 换页 f | 不支持 | 不支持 | 高版本支持 | f | f | 另义 f表示文件名字符 | f |
| 换行 n | 不支持 | 不支持 | 不支持 | n | n | n | n |
| 回车 r | 不支持 | 不支持 | r | r | r | r | r |
| 空白 s | 不支持 | 不支持 | 不支持 | 不支持 | s | s | s |
| 非空白 S | 不支持 | 不支持 | 不支持 | 不支持 | S | S | S |
| 制表符 t | 不支持 | 不支持 | 高版本支持 | t | t | t | t |
| 垂直制表符 v | 不支持 | 不支持 | 高版本支持 | v | v | 另义 v表示very magic | v |
| 单词字符 w [A-Za-z0-9_] | w | w | w | 不支持 | w | w | w |
| 非单词字符 W [^A-Za-z0-9] | W | W | W | 不支持 | W | W | W |
| xn 16进制 | 不支持 | 不支持 | 高版本支持 | xn | xn | 另义 x表示[0-9A-Za-z] | xn |
| n 八进制 | 不支持 | 不支持 | 不支持 | n | n | 不支持 | n |
| n 后向引用 | n | n | n | n 仅取结果可用 | n | n 仅取结果可用 | n |
| [:alnum:] 字母和数字 | [:alnum:] | [:alnum:] | [:alnum:] | [:alnum:] | [:alnum:] | [:alnum:] | 不支持 |
| [:alpha:] 字母 | [:alpha:] | [:alpha:] | [:alpha:] | [:alpha:] | [:alpha:] | [:alpha:] | 不支持 |
| [:cntrl:] 控制字符 | [:cntrl:] | [:cntrl:] | [:cntrl:] | [:cntrl:] | [:cntrl:] | [:cntrl:] | 不支持 |
| [:digit:] 数字 | [:digit:] | [:digit:] | [:digit:] | [:digit:] | [:digit:] | [:digit:] | 不支持 |
| [:graph:] 可打印字符(不含空格) | [:graph:] | [:graph:] | [:graph:] | [:graph:] | [:graph:] | [:graph:] | 不支持 |
| [:lower:] 小写 | [:lower:] | [:lower:] | [:lower:] | [:lower:] | [:lower:] | [:lower:] | 不支持 |
| [:print:] 可打印字符(含空格) | [:print:] | [:print:] | [:print:] | [:print:] | [:print:] | [:print:] | 不支持 |
| [:punct:] 标点 | [:punct:] | [:punct:] | [:punct:] | [:punct:] | [:punct:] | [:punct:] | 不支持 |
| [:space:] 空格 | [:space:] | [:space:] | [:space:] | [:space:] | [:space:] | [:space:] | 不支持 |
| [:upper:] 大写字母 | [:upper:] | [:upper:] | [:upper:] | [:upper:] | [:upper:] | [:upper:] | 不支持 |
| [:xdigit:] 16进制数字 | [:xdigit:] | [:xdigit:] | [:xdigit:] | [:xdigit:] | [:xdigit:] | [:xdigit:] | 不支持 |
| [:return:] | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | [:return:] | 不支持 |
| [:tab:] | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | [:tab:] | 不支持 |
| [:escape:] | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | [:escape:] | 不支持 |
| [:backspace:] | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | [:backspace:] | 不支持 |
centos vpn二
0网络实验环境:
双网卡AS5.0 VPN服务器:eth0=192.168.10.1 eth1=192.168.20.1,eth0内网卡,虚拟网络vmnet2,eth1外网卡,虚拟网络桥接。
内网服务器IP地址:192.168.10.1
外网PC机,做VPN客户端,IP地址:192.168.20.2
一、 软件包
1、dkms-2.0.17.5-1.noarch.rpm
2、kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
MPPE(Microsoft Point to Point Encryption,微软点对点加密)
3、ppp-2.4.4-9.0.rhel5.i386.rpm(AS5.0光盘默认就有)
PPP(Point-to-Point Protocol,点到点协议)
4、pptpd-1.3.4-1.rhel5.1.i386.rpm
wget http://poptop.sourceforge.net/yum/stable/packages/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
wget http://poptop.sourceforge.net/yum/stable/packages/ppp-2.4.4-9.0.rhel5.i386.rpm
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-1.rhel5.1.i386.rpm
rpm -ivh ppp-2.4.4-9.0.rhel5.i386.rpm
rpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm
安装时注意顺序
三、编辑pptpd主配置文件
1、#vim /etc/pptpd.conf
localip 后面要改为你服务器的外网IP地址:192.168.20.1,也就是VPN客户端拨号的IP地址。
remoteip 后面改为你分配给VPN用户的IP段….比如192.168.10.100-200
2、#vi /etc/ppp/options.pptpd 修改内容如下:
一般只需修改ms-dns,分配给VPN客户端的DNS服务器IP地址
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 202.101.224.68
proxyarp
3、重启pptpd服务器
四、 增加VPN用户和密码,会立即生效的。
在/etc/ppp/chap-secrets增加两行分别对应如下:
“test@gd.cn” * ”test” *
上面第二行代码的四项内容分别对应第一行中的四项。“test@gd.cn” 是Client端的VPN用户名;“server”对应的是VPN服务器的 名字,该名字必须和/etc/ppp/options.pptpd文件中指明的一样,或者设置成“*”号来表示自动识别服务器;“secret”对应的是 登录密码;“IP addresses”对应的是可以拨入的客户端IP地址,如果不需要做特别限制,可以将其设置为“*”号。
五、 开启路由转发
可以将这条命令放到文件/etc/rc.d/rc.local里面,以实现每次开机时自动运行该命令。
#/sbin/iptables -A INPUT -p tcp –dport 47 -j ACCEPT
#/sbin/iptables -A INPUT -p gre -j ACCEPT
我们还需要设置NAT IP转发.否则用户连接上服务器后.是不能访问外网的内容的.
设置方法也很简单的.
代码:
iptables -t nat -F
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j SNAT --to 999.999.999.999
上面的192.168.10.0替换成你要分配给客户用的VPN 内网IP段
999.999.999.999 替换成你的VPN服务器IP [与上面PPTPD.CONF的LOCALIP一样]
最后我们打开LINUX服务器的IP转发功能就大功告成了
Linux vpn 配置
0安装环境:RHEL4 update 1
一,下载VPN服务器所需软件
dkms-2.05-1.noarch.rpm
动态内核模块支持的RPM安装包
kernel_ppp_mppe-0.0.5-2dkms.noarch.rpm
MPPE加密协议的内核补丁的RPM安装包
ppp-2.4.3-5.rhel4.i386.rpm
升级内置PPP到2.4.3版本,以支持MPPE加密协议
pptpd-1.3.0-0.i386.rpm
pptp点对点隧道协议的RPM安装包
下载地址:
http://prdownloads.sourceforge.net/poptop/
rpm -ivh dkms-~
rpm -ivh kernel_ppp_~
rpm -Uvh ppp-2.~
rpm -ivh pptpd-1.3~
修改/etc/pptpd.conf和/etc/ppp/chap-secrets文件来配置VPN服务器的运行参数
主配置文件:
vi /etc/pptpd.conf
加入以下配置语句:
localip 192.168.1.115
remoteip 192.168.16.0-192.168.16.254,192.168.1.254
#localip 本地VPN服务器所使用的IP地址,供VPN客户端连接使用。
#remoteip 分配给VPN客户机的地址段。可以使用“-”表示一个段,也可以使用“,”隔开不连续的地址。
配置帐号文件:
vi /etc/ppp/chap-secrets
该文件保存了VPN客户端拨入时所使用的帐户名,口令,和分配的IP地址,格式为:
帐户名 服务 口令 分配给该帐户的IP地址
“test” pptpd “test” “*”
“test2″ pptpd “test2″ “192.168.1.254″
打开Linux内核的路由功能
为了能让VPN客户机与内部网络互联,还应打开Linux内核的路由功能,否则VPN客户端只能访问VPN服务器的内部网卡,所以需打开Linux内核的路由功能。
echo “1″>/proc/sys/net/ipv4/ip_forward
启动和停止VPN服务:
启动:/etc/init.d/pptpd start
停止:/etc/init.d/pptpd stop
重启:/etc/init.d/pptpd restart
# pptpd restart-kill :在停止VPN服务时,断开所有的已经存在的VPN连接,然后使用命令/etc/init.d/pptpd start 启动VPN服务。
自动启动VPN服务
ntsysv
选中pptpd
防火墙设置:
说明:pptp服务使用TCP协议的1723端口和编号47的IP协议(GRE常规路由封装)。如果Linux服务器开启了防火墙功能,就需关闭防火墙功能或设置允许TCP协议的1723端口和编号47的IP协议通过,如可以使用以下命令开放TCP协议的1723端口和编号为47的IP协议
iptables -I INPUT -p tcp –dport 1723 -j ACCEPT
iptables -I INPUT -P gre -j ACCEPT
参考文章:
http://fanqiang.chinaunix.net/app/vpn/2005-04-06/3112.shtml
PPTP连接异常断开,VPN服务器上还保留连接
这种情况多为用户拨入后异常断开如直接拨网线,VPN服务器没有及时检测到中断信号,所以存在一个死连接(有时死连接存在10个小时以上或一直存在)。对于Linux平台的VPN服务器,大部分异常断开后,服务器的 pptpctrl程序会中断连接,但有时无法中断,导致死连接的存在。
ifconfig pppX down把死链中断
为 CentOS 添加 网易/163 的 yum 源[zt]
0以超级用户登路
先关闭 fastestmirror
“vi /etc/yum/pluginconf.d/fastestmirror.conf” and set “enable=0″
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
yum makecache
yum update
now enjoy it!