The new features given by the authorities are as follows:
PHP 7.0.0 comes with new version of the Zend Engine with features such as (incomplete list):
Improved performance:php 7 is up to twice as fast as PHP 5.6
Consistent 64-bit Support
Many fatal errors are now exceptions
Removal of the old and unsupported Sapis and extensions
The null coalescing operator (??)
Combined comparison Operator (<=>)
return Type Declarations
Scalar Type Declarations
Anonymous Classes
As for the new features, Baidu has given a very detailed explanation, but I do not understand, but I read a:
Improved performance:php 7 is up to twice as fast as PHP 5.6
The performance of PHP7 will be twice times that of PHP5.6!
Well, the others do not have to look, single this one has been upgraded the momentum of it!
Previously used the RC version, performance did improve a lot, but in the PHP7.0 environment, the begin theme There are many problems, because it is not a formal version, I will not bother to spend time to solve.
Today, the official release of the official version, so the use of time to compile the blog to install the PHP7.0, and to solve the begin theme is still incompatible issues, the following simple to share.
First, compile the installation
The following installation steps are carried out in an existing PHP5 environment and are not guaranteed to be successfully completed for informational purposes only.
①, download PHP
Cd/usr/local/src
#下载安装包
wget http://cn2.php.net/distributions/php-7.0.0.tar.gz
This is the official version of PHP PHP7.0 National CDN Download address, can be assured to download.
②, decompression and compilation
The basic big guys have already installed PHP 5.6 or older versions, so we can compile and install to a new path.
#进入安装目录
CD php-7.0.0
#编译安装
#因为是在已经有PHP5.6 installed in the environment, the following parameters will not be an error, if the error, then the lack of what to fill it!
cflags= cxxflags=./configure--prefix=/usr/local/php7--with-config-file-path=/usr/local/php7/etc \
--with-fpm-user=www--with-fpm-group=www--enable-fpm--enable-opcache \
--disable-fileinfo--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-jpeg-dir \
--with-iconv-dir=/usr/local--with-freetype-dir--with-png-dir--with-zlib--disable-rpath \
--WITH-LIBXML-DIR=/USR--enable-xml--enable-bcmath--enable-shmop--enable-exif--with-curl \
--enable-sysvsem--enable-inline-optimization--enable-mbregex--enable-inline-optimization \
--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl \
--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-ftp \
--with-gettext--enable-zip--enable-soap--disable-ipv6--disable-debug
#继续make
Make zend_extra_libs= '-liconv '
#最后make Install complete the installation
Make install
The above compiled installation activates the Opcache cache, which is recommended for personal use if you do not need to remove--enable-opcache.
③, setting parameters
#以下操作均在php -7.0.0 This installation directory to execute
Php_install_dir=/usr/local/php7
CP php.ini-production $php _install_dir/etc/php.ini
Mem= ' Free-m | awk '/mem:/{print $} '
If [$Mem-gt 1024-a $Mem-le 1500];then
memory_limit=192
elif [$Mem-gt 1500-a $Mem-le 3500];then
memory_limit=256
elif [$Mem-gt 3500-a $Mem-le 4500];then
memory_limit=320
elif [$Mem-gt 4500];then
memory_limit=448
Else
memory_limit=128
Fi
Sed-i "s@^memory_limit.* @memory_limit = ${memory_limit}m@" $php _install_dir/etc/php.ini
Sed-i ' s@^output_buffering = @output_buffering = on\noutput_buffering =@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;cgi.fix_pathinfo.* @cgi. fix_pathinfo=0@ ' $php _install_dir/etc/php.ini
Sed-i ' S@^short_open_tag = Off@short_open_tag = on@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^expose_php = on@expose_php = off@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^request_order.* @request_order = ' CGP ' @ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;d ate.timezone.* @date. TimeZone = asia/shanghai@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^post_max_size.* @post_max_size = 50m@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^upload_max_filesize.* @upload_max_filesize = 50m@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;upload_tmp_dir.* @upload_tmp_dir =/tmp@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^max_execution_time.* @max_execution_time = 600@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;realpath_cache_size.* @realpath_cache_size = 2m@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^disable_functions.* @disable_functions = Passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open, Proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, fsocket,popen@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^session.cookie_httponly.* @session. cookie_httponly = 1@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^mysqlnd.collect_memory_statistics.* @mysqlnd. Collect_memory_statistics = on@ ' $php _install_dir/etc/ Ini
[-e/usr/sbin/sendmail] && sed-i ' s@^;sendmail_path.* @sendmail_path =/usr/sbin/sendmail-t-i@ ' $php _install_d Ir/etc/php.ini
#如果编译时去掉了--enable-opcache, the following include Opcache are ignored
Sed-i ' s@^\[opcache\]@[opcache]\nzend_extension=opcache.so@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.enable=.* @opcache. enable=1@ ' $php _install_dir/etc/php.ini
Sed-i "s@^;opcache.memory_consumption.* @opcache. memory_consumption= $Memory _limit@" $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.interned_strings_buffer.* @opcache. interned_strings_buffer=8@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.max_accelerated_files.* @opcache. max_accelerated_files=4000@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.revalidate_freq.* @opcache. revalidate_freq=60@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.save_comments.* @opcache. save_comments=0@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.fast_shutdown.* @opcache. fast_shutdown=1@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.validate_timestamps.* @opcache. validate_timestamps=1@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.enable_cli.* @opcache. enable_cli=1@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.use_cwd.* @opcache. use_cwd=1@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^opcache.max_accelerated_files.* @opcache. max_accelerated_files=100000@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.max_wasted_percentage.* @opcache. max_wasted_percentage=5@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.consistency_checks.* @opcache. consistency_checks=0@ ' $php _install_dir/etc/php.ini
Sed-i ' s@^;opcache.optimization_level.*@;opcache.optimization_level=0@ ' $php _install_dir/etc/php.ini
# PHP-FPM directly with the previous configuration can be
Cp-f/usr/local/php/etc/php-fpm.conf/usr/local/php7/etc/
Ps: The above parameters such as code from the LNMP one-click installation package extraction.
④, version substitution
PHP 7 has been installed to the/USR/LOCAL/PHP7, in order to allow 2 versions for the time being, easy to transition, here we use soft links to fix
#停止php-FPM
Service PHP-FPM Stop
#重命名php老版本
Cd/usr/local
mv/php PHP5
#建立php7的软链接
Ln-s php7 PHP
#启动php-FPM
Service PHP-FPM Start
Oh, finish the above steps, if not the error is basically already done, the implementation of PHP--version should be able to see version information
PHP 7.0.0 (CLI) (Built:dec 2 2015 19:44:28) (NTS)
Copyright (c) 1997-2015 the PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
With Zend Opcache V7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Ii. Problem-solving
After upgrading to PHP7, the site does not have an unexpected white screen! But, do not panic, calm down to see what is the problem.
①, incompatible with certain PHP encryption schemes
Edit wp-config.php directly and insert the following to turn on the error display of PHP:
Error_reporting (E_all);
Ini_set (' display_errors ', Ƈ ');
To be on the safe side, refresh the next PHP because Opcache may have caching:
Service PHP-FPM Reload
Refresh the site again, found that the original is the brother of the initial encryption of the error, it seems that PHP7 does not support this form of encryption. All right, let's find brother Bird. A copy of the Begin without encryption, continue the test.
②, repeating function conflicts
After replacing the latest unencrypted begin topic, no surprises or errors ...
Look, it's brother Bird. The function that automatically updates the archive page is added to the topic, and my child theme already has a function conflict.
Direct annotation one, fix!
③, Comments no content
Solve the above several problems, is enjoying the speed of PHP7 brought about by the excitement, suddenly found that the front desk and backstage do not show comments content! Displays only information such as comment authors.
Suddenly remembered before the test PHP7 RC version appeared, but did not delve directly to give up.
The positioning method is simple, turn on all the error display of PHP again, and then refresh the background comment interface, found the following error:
It turns out that the Preg_replace function has deprecated the/e parameter in PHP7, instead of the Preg_replace_callback function.
So, find the error point to the file and function, found that the comment mapping function, so the/e removed or changed to/I tried, temporarily did not find any problems, estimated mapping features will be abnormal bar!
There is no time to study how to replace the Preg_replace_callback function, followed by a specific study.
Three, simple test
The problem has been solved and the performance should be tested.
However, has never been a professional performance testing tool, a rough one, directly visual background of the same page load effect.
PHP 5.6 Load WordPress Backstage "All articles" page, head response time consuming 2.6s
PHP 7.0 Load WordPress backstage "All articles" page, head response time consuming 1.5s
Simple visual inspection has been the score! Absolutely not psychological effect, background speed promotion is quite obvious.
Of course, I always use the blog front of the pure static, so upgrade PHP7 also just to enhance their background experience!
There is time behind, and then detailed in-depth testing of the performance of the PHP7 bar!
Original from: http://zhangge.net/5075.html