|
1.下载源码包并解压
源码包地址:http://php.net/downloads.php [root@localhost phpSrc]# wget -P ./ https://www.php.net/distributions/php-7.4.6.tar.gz
--2022-09-05 01:31:41-- https://www.php.net/distributions/php-7.4.6.tar.gz
Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad
Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16501931 (16M) [application/octet-stream]
Saving to: ‘./php-7.4.6.tar.gz’
100%[=====================================================================>] 16,501,931 2.27MB/s in 7.9s
2022-09-05 01:31:52 (2.00 MB/s) - ‘./php-7.4.6.tar.gz’ saved [16501931/16501931]解压源码包:
[root@localhost phpSrc]# tar -zxvf php-7.4.6.tar.gz
[root@localhost phpSrc]# ls
php-7.4.6 php-7.4.6.tar.gz
[root@localhost phpSrc]# cd php-7.4.6/
[root@localhost php-7.4.6]# ls
appveyor CODING_STANDARDS.md EXTENSIONS php.ini-production tests Zend
azure configure LICENSE README.md travis
azure-pipelines.yml configure.ac main README.REDIST.BINS TSRM
build CONTRIBUTING.md NEWS run-tests.php UPGRADING
buildconf docs pear sapi UPGRADING.INTERNALS
buildconf.bat ext php.ini-development scripts win322.编译安装
首先安装PHP编译安装所必须的软件
[root@localhost php-7.4.6]# yum -y install gcc gcc++ libxml2-devel libicu-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.nju.edu.cn
* extras: mirrors.nju.edu.cn
* updates: ftp.sjtu.edu.cn
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version
No package gcc++ available.
Package libxml2-devel-2.9.1-6.el7_9.6.x86_64 already installed and latest version
Package libicu-devel-50.2-4.el7_7.x86_64 already installed and latest version
Nothing to doconfigure预编译安装依赖包
[root@localhost php-7.4.6]# yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.nju.edu.cn
* extras: mirrors.nju.edu.cn
* updates: ftp.sjtu.edu.cn
Package libxml2-2.9.1-6.el7_9.6.x86_64 already installed and latest version
Package libxml2-devel-2.9.1-6.el7_9.6.x86_64 already installed and latest version
Package 1:openssl-1.0.2k-25.el7_9.x86_64 already installed and latest version
Package 1:openssl-devel-1.0.2k-25.el7_9.x86_64 already installed and latest version
Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
Package bzip2-devel-1.0.6-13.el7.x86_64 already installed and latest version
Package libcurl-7.29.0-59.el7_9.1.x86_64 already installed and latest version
Package libcurl-devel-7.29.0-59.el7_9.1.x86_64 already installed and latest version
Package libjpeg-turbo-1.2.90-8.el7.x86_64 already installed and latest version
Package libjpeg-turbo-devel-1.2.90-8.el7.x86_64 already installed and latest version
Package 2:libpng-1.5.13-8.el7.x86_64 already installed and latest version
Package 2:libpng-devel-1.5.13-8.el7.x86_64 already installed and latest version
Package freetype-2.8-14.el7_9.1.x86_64 already installed and latest version
Package freetype-devel-2.8-14.el7_9.1.x86_64 already installed and latest version
Package 1:gmp-6.0.0-15.el7.x86_64 already installed and latest version
Package 1:gmp-devel-6.0.0-15.el7.x86_64 already installed and latest version
No package libmcrypt available.
No package libmcrypt-devel available.
Package readline-6.2-11.el7.x86_64 already installed and latest version
Package readline-devel-6.2-11.el7.x86_64 already installed and latest version
Package libxslt-1.1.28-6.el7.x86_64 already installed and latest version
Package libxslt-devel-1.1.28-6.el7.x86_64 already installed and latest version
Package zlib-1.2.7-20.el7_9.x86_64 already installed and latest version
Package zlib-devel-1.2.7-20.el7_9.x86_64 already installed and latest version
Package glibc-2.17-326.el7_9.x86_64 already installed and latest version
Package glibc-devel-2.17-326.el7_9.x86_64 already installed and latest version
Package glib2-2.56.1-9.el7_9.x86_64 already installed and latest version
Package glib2-devel-2.56.1-9.el7_9.x86_64 already installed and latest version
Package ncurses-5.9-14.20130511.el7_4.x86_64 already installed and latest version
Package curl-7.29.0-59.el7_9.1.x86_64 already installed and latest version
Package gdbm-devel-1.10-8.el7.x86_64 already installed and latest version
No package db4-devel available.
Package libXpm-devel-3.5.12-1.el7.x86_64 already installed and latest version
Package libX11-devel-1.6.7-4.el7_9.x86_64 already installed and latest version
Package gd-devel-2.0.35-27.el7_9.x86_64 already installed and latest version
Package 1:gmp-devel-6.0.0-15.el7.x86_64 already installed and latest version
Package expat-devel-2.1.0-14.el7_9.x86_64 already installed and latest version
Package xmlrpc-c-1.32.5-1905.svn2451.el7.x86_64 already installed and latest version
Package xmlrpc-c-devel-1.32.5-1905.svn2451.el7.x86_64 already installed and latest version
Package libicu-devel-50.2-4.el7_7.x86_64 already installed and latest version
No package libmcrypt-devel available.
Package libmemcached-devel-1.0.16-5.el7.x86_64 already installed and latest version
Nothing to do执行./configure预编译安装依赖包
[root@localhost php-7.4.6]# ./configure --prefix=/usr/local/php-7.4.6 --with-config-file-path=/usr/local/php-7.4.6/lib/ --disable-ipv6 --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=daemon --with-fpm-group=daemon --with-gd --with-iconv --with-zlib --enable-xml --enable-mbstring --disable-mbregex --with-openssl --with-gettext --with-curl --enable-opcache --with-bz2 --without-gdbm --enable-sockets --enable-zip预编译成功时的输出结果
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.编译&安装
[root@localhost php-7.4.6]# make && make install
...
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php-7.4.6/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary: /usr/local/php-7.4.6/bin/
Installing PHP CLI man page: /usr/local/php-7.4.6/php/man/man1/
Installing PHP FPM binary: /usr/local/php-7.4.6/sbin/
Installing PHP FPM defconfig: /usr/local/php-7.4.6/etc/
Installing PHP FPM man page: /usr/local/php-7.4.6/php/man/man8/
Installing PHP FPM status page: /usr/local/php-7.4.6/php/php/fpm/
Installing phpdbg binary: /usr/local/php-7.4.6/bin/
Installing phpdbg man page: /usr/local/php-7.4.6/php/man/man1/
Installing PHP CGI binary: /usr/local/php-7.4.6/bin/
Installing PHP CGI man page: /usr/local/php-7.4.6/php/man/man1/
Installing build environment: /usr/local/php-7.4.6/lib/php/build/
Installing header files: /usr/local/php-7.4.6/include/php/
Installing helper programs: /usr/local/php-7.4.6/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php-7.4.6/php/man/man1/
page: phpize.1
page: php-config.1
/home/phpSrc/php-7.4.6/build/shtool install -c ext/phar/phar.phar /usr/local/php-7.4.6/bin
ln -s -f phar.phar /usr/local/php-7.4.6/bin/phar
Installing PDO headers: /usr/local/php-7.4.6/include/php/ext/pdo/
3.性能测试对比php5|php7|php8
[root@localhost phpSrc]# /usr/local/php-5.6.37/bin/php ./php-5.6.37/Zend/bench.php
simple 0.053
simplecall 0.077
simpleucall 0.077
simpleudcall 0.080
mandel 0.138
mandel2 0.191
ackermann(7) 0.070
ary(50000) 0.016
ary2(50000) 0.014
ary3(2000) 0.111
fibo(30) 0.254
hash1(50000) 0.026
hash2(500) 0.023
heapsort(20000) 0.062
matrix(20) 0.069
nestedloop(12) 0.110
sieve(30) 0.082
strcat(200000) 0.009
------------------------
Total 1.461
[root@localhost phpSrc]# /usr/local/php-7.4.6/bin/php ./php-5.6.37/Zend/bench.php
simple 0.018
simplecall 0.006
simpleucall 0.014
simpleudcall 0.018
mandel 0.075
mandel2 0.076
ackermann(7) 0.015
ary(50000) 0.003
ary2(50000) 0.002
ary3(2000) 0.031
fibo(30) 0.053
hash1(50000) 0.009
hash2(500) 0.007
heapsort(20000) 0.019
matrix(20) 0.018
nestedloop(12) 0.032
sieve(30) 0.011
strcat(200000) 0.004
------------------------
Total 0.413
[root@localhost phpSrc]# /usr/local/php-8.1.10/bin/php ./php-5.6.37/Zend/bench.php
simple 0.008
simplecall 0.004
simpleucall 0.014
simpleudcall 0.014
mandel 0.077
mandel2 0.082
ackermann(7) 0.015
ary(50000) 0.003
ary2(50000) 0.002
ary3(2000) 0.028
fibo(30) 0.055
hash1(50000) 0.006
hash2(500) 0.007
heapsort(20000) 0.017
matrix(20) 0.017
nestedloop(12) 0.015
sieve(30) 0.010
strcat(200000) 0.003
------------------------
Total 0.3784.参考资料 |
|