100%

if( true )

1/2

if( rand(0,1) === 0 )

1/3

if( rand(0,2) === 0 )

1/4

if( rand(0,3) === 0 )

1/x

if( rand(0,x) === 0 )

x%

if( rand(0,99) < x )

x‰

if( rand(0,999) < x )

x‱

if( rand(0,9999) < x )

/**
* 以$x/$y的概率返回true
*
* @param int $x
* @param int $y
* @return bool
*
* prob(1,2) = 1/2
* prob(1,100) = 1/100
*
*/
function prob($x, $y){
return ( mt_rand(0, $y-1) < $x );
}

手动下载几个依赖包:

[shell]wget http://mirrors.sohu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_i386.deb
wget http://mirrors.sohu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu0.2_i386.deb[/shell]

安装:

[shell]sudo dpkg -i *.deb[/shell]

加入php5源

[shell]sudo echo “deb http://php53.dotdeb.org stable all” >> /etc/apt/sources.list[/shell]

更新源

[shell]sudo apt-get update[/shell]

apt安装

[shell]sudo apt-get install php5-cli php5-common php5-suhosin
sudo apt-get install php5-fpm php5-cgi
[/shell]

如果需要安装php5-mcrypt ,php5-dev,需要手动安装以下依赖包

[shell]# apt-get install php5-mcrypt
wget http://mirrors.sohu.com/debian/pool/main/libt/libtool/libltdl3_1.5.26-4+lenny1_i386.deb
# apt-get install php5-dev
wget http://mirrors.sohu.com/ubuntu/pool/main/libt/libtool/libtool_1.5.26-1ubuntu1_i386.deb[/shell]