安装环境centos 5.8 64位
1、下载并解压php7
2、先安装依赖包。
yum install systemtap systemtap-sdt-devel bzip2-devel.x86_64 gdbm-devel db4-devel openldap-devel readline-devel libedit-devel
3、创建安装目录
mkdir /home/work/app/php7
4、./configure --prefix=/home/work/app/php7 --with-config-file-path=/home/work/app/php7/etc --enable-bcmath --enable-calendar --with-pdo-mysql -enable-exif --enable-ftp --enable-gd-native-ttf --enable-mbregex --with-mysql-sock --enable-mbstring --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-jpeg-dir --with-kerberos= --with-libedit --with-mhash --with-openssl --with-png-dir --with-xmlrpc --with-zlib --with-bz2 --disable-debug --enable-fpm --with-curl --with-xsl --with-ldap --with-ldap-sasl --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --enable-pcntl --enable-dtrace --enable-zend-signals
5、make & make install
如何大家有其它错误可以参考下方错误列表
http://lyp.cn/350_how-to-fix-php-compile-errors
测试了性能,针对php7主php5.4
分别运行100万次hash函数
list($sec,$mis) = explode(' ',microtime());
for($i = 0;$i<1000000;$i++){
myHash($i);
}
function myHash($p){
$md5Str = md5(mt_rand(1000,9999)+$p);
$seed = 32;
$hash = 0;
$bitStr = substr($md5Str,0,8);
for($j = 0;$j < 8;$j++){
$hash = $hash*$seed+ord($bitStr[$j]);
}
return $hash & 0x7FFFFFFF;
}
list($sec2,$mis2) = explode(' ',microtime());
php7性能确实为php5.4的两倍
php7结果1秒:
0.47782200,1434167189
0.49571300,1434167190
php5.4为2.1秒
0.93335000,1434167282
0.81659100,1434167284