In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how PHP7 passes the yum source installation and performance testing. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
When it comes to PHP, some people will surely say that it is the best programming language in the world. In terms of popularity alone, more than 81.7% of the world's server backends use PHP, which drives more than 200 million websites around the world. The official version of PHP7 was released early last month, ushering in the biggest update since 2004. Now PHP 7. 0 is officially released.
For ordinary PHP sites, it is mainly IO-intensive, and the bottleneck is on MySQL data, which does not reflect the disadvantage of PHP performance. But in terms of intensive computing, it is dozens or even hundreds of times worse than statically compiled languages such as C, C++ and Java. If a more complex framework, such as symfony, is used in PHP development, the program performance will degrade significantly. In fact, the PHP language was not originally designed to solve computing-intensive application scenarios. We can roughly understand that PHP sacrifices execution efficiency in order to improve development efficiency.
But PHP is quite popular, such as Sina Weibo, Facebook, such as large websites, most programs are written in PHP, that is, in this large-scale application, the poor performance of PHP appears. Much of the early code in Facebook was developed using PHP, but with the rapid development of the business, PHP execution efficiency has become a more and more obvious problem. To optimize execution efficiency, Facebook started using HipHop, a PHP execution engine, in 2008, originally to convert a large amount of Fackbook's PHP code into Clearing codes to improve performance and save resources. The performance of PHP code that uses HipHop has been improved several times. Later, Facebook made the HipHop platform open source and gradually developed into what is now HHVM. HHVM is used to replace the engine Zend Engine used by PHP itself. Performance is said to have improved by 70%. Of course, PHP officials also know the biggest weakness of PHP, so they launched the PHP7 project, mainly refactoring the Zend Engine engine.
The most significant change in PHP7 is the great improvement in performance, which is close to HHVM, the PHP execution engine developed by Facebook. In the WordPress benchmark performance test, the speed is 2-3 times faster than version 5.6, greatly reducing memory footprint. PHP7 also has some language changes, such as the addition of return type declarations, the addition of some new reserved keywords, and so on. In terms of security, remove PHP security mode, add magic quotation marks and so on. Not only that, the new version also supports 64-bit and includes the latest version of the Zend engine. In fact, the performance of PHP7 in real scenarios is indeed comparable to that of HHVM, and even surpasses HHVM in some scenarios. But the operation and maintenance of HHVM is complex, and it is a multithreaded model, which means that if a thread causes crash, the whole service will fail and it will not restart automatically. In addition, it uses JIT, which means that it needs to be preheated after restart, and the performance is poor without preheating. And it is difficult to debug the multithreaded model, which is very inappropriate for Web services in pursuit of stability.
YUM install PHP7
If you want to use the latest version of PHP, you need to use the REMI source. Remi repository is the Linux source that contains the latest version of PHP and the MySQL package, and is maintained by Remi. After having this source, use YUM to install or update newer versions of PHP and MySQL.
Install the latest Remi source automatic installation files
# CentOS 6 / RHEL 6yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm# CentOS 7 / RHEL 7yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install PHP-related components, and the following is a standard installation that can be used in a production environment.
$yum-- enablerepo=remi,remi-php70 installphp\ php-cgi\ php-cli\ php-fpm\ php-common\ php-devel\ php-mysqlnd\ php-mysql\ php-mbstring\ php-msgpack\ php-mcrypt\ php-bcmath\ php-gd\ php-xml\ php-ldap\ php-xmlrpc\ php-opcache\ php-curl\ php-json\ php-odbc\ php-pdo\ php-bz2\ php-xml\ php-ftp\ php-imap\ php-snmp\ php-redis\ php-memcached
View PHP version
$php-vPHP 7.0.9 (cli) (built: Jul 20 2016 18:08:08) (NTS)
Start PHP-FPM
$service php-fpm start
At this point, the PHP7.0 installation is complete. If you need to use PHP extension features, such as redis, memcached, etc., you only need to install it using YUM, as follows:
$yum-enablerepo=remi,remi-php70 install php-redis php-memcached
If you can't find the extension module you need in either the REMI or EPEL source, it's easy to compile and install it manually.
Also use the php-m command to view the PHP module information.
$php-m | grep redisredis
Install a set of LNMP reference: LNMP installation package deployment practice or refer to the PHP7.0 version of LNMPZabbix 3.0 installation and use details
PHP7 performance test
Environment: 4-core CPU, 4G memory, operating system Centos 6.5.
First of all, let me talk about the suggestion of the GCC compiler. According to Bird's suggestion, using a newer compiler, more than GCC 4.8 is recommended, because only PHP above GCC 4.8 will enable Global Register for opline and execute_data support, which will bring about a 5% performance improvement.
Write a program (a simple test method available online):
In the first paragraph, an array of 600,000 elements is generated to determine whether the key exists by looking for key.
php$a = array (); for ($item0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.