Linux环境PHP7.0安装
linux版本:64位CentOS 6.5
php版本:php-7.0.0RC1
安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| wget https:
tar zxvf php-7.0.0RC1.tar.gz cd php-7.0.0RC1 ./configure --help ./configure --prefix=/usr/local/php \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip
|
如果配置错误,需要安装需要的模块,直接yum一并安装依赖库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
yum -y install curl-devel yum -y install libxslt-devel
su yum install openssl openssl-devel
should be in <curl-dir>/include/curl/
yum install curl curl-devel
yum install libxslt-devel
|
编译安装
1 2 3 4 5 6 7 8 9 10
| make && make install cp php.ini-development /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
/etc/init.d/php-fpm
|
测试
php7和php5性能分析比较
新建文件search_by_key.php
1 2 3 4 5 6 7 8 9 10 11 12
| <?php
$a = array(); for($i=0;$i<600000;$i++){ $a[$i] = $i; } foreach($a as $i) { array_key_exists($i, $a); } ?>
|
time /usr/local/php/bin/php search_by_key.php //php7
php7环境下测试

1 2
| time /usr/bin/php search_by_key.php //php5.4.38
|
php5.4.38环境下测试

分析
php7速度
real 0m0.013s
user 0m0.010s
sys 0m0.002s
php 5.4.38速度,明显php7速度快很多
real 0m0.054s
user 0m0.016s
sys 0m0.008s
参考文章 http://blog.csdn.net/21aspnet/article/details/47708763