{"id":136139,"date":"2019-02-22T10:52:26","date_gmt":"2019-02-22T02:52:26","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=136139"},"modified":"2019-02-18T09:55:36","modified_gmt":"2019-02-18T01:55:36","slug":"php7-install-test","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/php7-install-test.html","title":{"rendered":"PHP7\u901a\u8fc7yum\u6e90\u5b89\u88c5\u53ca\u6027\u80fd\u6d4b\u8bd5"},"content":{"rendered":"
\u63d0\u5230PHP\uff0c\u80af\u5b9a\u4f1a\u6709\u4eba\u8bf4\u8fd9\u662f\u4e16\u754c\u4e0a\u6700\u597d\u7684\u7f16\u7a0b\u8bed\u8a00\u3002\u5355\u8bf4\u6d41\u884c\u7a0b\u5ea6\uff0c\u76ee\u524d\u5168\u7403\u8d85\u8fc781.7%\u7684\u670d\u52a1\u5668\u540e\u7aef\u90fd\u91c7\u7528\u4e86PHP\u8bed\u8a00\uff0c\u5b83\u9a71\u52a8\u7740\u5168\u7403\u8d85\u8fc72\u4ebf\u591a\u4e2a\u7f51\u7ad9\u3002\u4e0a\u6708\u521dPHP7\u6b63\u5f0f\u7248\u53d1\u5e03\uff0c\u8fce\u6765\u81ea2004\u5e74\u4ee5\u6765\u6700\u5927\u7684\u7248\u672c\u66f4\u65b0\u3002\u73b0\u5728PHP 7.0\u6b63\u5f0f\u53d1\u5e03\u3002<\/p>\n
\u5bf9\u4e8e\u666e\u901a\u7684PHP\u7f51\u7ad9\uff0c\u4e3b\u8981\u662fIO\u5bc6\u96c6\u578b\u7684\uff0c\u74f6\u9888\u5728MySQL\u6570\u636e\u4e4b\u4e0a\uff0c\u4f53\u73b0\u4e0d\u51fa\u6765PHP\u6027\u80fd\u7684\u52a3\u52bf\u3002\u4f46\u5728\u5bc6\u96c6\u8ba1\u7b97\u65b9\u9762\u6bd4C\u3001C++\u3001Java\u8fd9\u79cd\u9759\u6001\u7f16\u8bd1\u578b\u8bed\u8a00\u5dee\u51e0\u5341\u500d\u751a\u81f3\u4e0a\u767e\u500d\u3002\u5982\u679c\u5728PHP\u5f00\u53d1\u4e2d\u4f7f\u7528\u4e86\u6bd4\u8f83\u590d\u6742\u7684\u6846\u67b6\uff0c\u5982symfony\uff0c\u7a0b\u5e8f\u6027\u80fd\u4f1a\u660e\u663e\u4e0b\u964d\u3002\u4e8b\u5b9e\u4e0a\uff0cPHP\u8bed\u8a00\u6700\u521d\u7684\u8bbe\u8ba1\uff0c\u5c31\u4e0d\u662f\u7528\u6765\u89e3\u51b3\u8ba1\u7b97\u5bc6\u96c6\u578b\u7684\u5e94\u7528\u573a\u666f\u3002\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u7c97\u7565\u7406\u89e3\u4e3a\uff0cPHP\u4e3a\u4e86\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u800c\u727a\u7272\u4e86\u6267\u884c\u6548\u7387\u3002<\/p>\n
\u4f46PHP\u6bd4\u8f83\u6d41\u884c\uff0c\u5982\u65b0\u6d6a\u5fae\u535a\u3001Facebook\u8fd9\u79cd\u5927\u578b\u7f51\u7ad9\u5927\u90e8\u5206\u7a0b\u5e8f\u90fd\u662f\u4f7f\u7528PHP\u5199\u7684\uff0c\u4e5f\u5c31\u662f\u5728\u8fd9\u79cd\u5927\u89c4\u6a21\u5e94\u7528\u4e0b\uff0cPHP\u6027\u80fd\u4f4e\u4e0b\u5c31\u663e\u73b0\u51fa\u6765\u4e86\u3002Facebook\u65e9\u671f\u7684\u5f88\u591a\u4ee3\u7801\u662f\u4f7f\u7528PHP\u6765\u5f00\u53d1\u7684\uff0c\u4f46\u662f\uff0c\u968f\u7740\u4e1a\u52a1\u7684\u5feb\u901f\u53d1\u5c55\uff0cPHP\u6267\u884c\u6548\u7387\u6210\u4e3a\u8d8a\u6765\u8d8a\u660e\u663e\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u4f18\u5316\u6267\u884c\u6548\u7387\uff0cFacebook\u57282008\u5e74\u5c31\u5f00\u59cb\u4f7f\u7528HipHop\uff0c\u8fd9\u662f\u4e00\u79cdPHP\u6267\u884c\u5f15\u64ce\uff0c\u6700\u521d\u662f\u4e3a\u4e86\u5c06Fackbook\u7684\u5927\u91cfPHP\u4ee3\u7801\u8f6c\u6210 C++\uff0c\u4ee5\u63d0\u9ad8\u6027\u80fd\u548c\u8282\u7ea6\u8d44\u6e90\u3002\u4f7f\u7528HipHop\u7684PHP\u4ee3\u7801\u5728\u6027\u80fd\u4e0a\u6709\u6570\u500d\u7684\u63d0\u5347\u3002\u540e\u6765\uff0cFacebook\u5c06HipHop\u5e73\u53f0\u5f00\u6e90\uff0c\u9010\u6e10\u53d1\u5c55\u4e3a\u73b0\u5728\u7684HHVM\u3002HHVM\u7528\u6765\u66ff\u6362PHP\u81ea\u8eab\u4f7f\u7528\u7684\u5f15\u64ceZend Engine\u3002\u636e\u8bf4\u6027\u80fd\u63d0\u5347\u4e8670%\u3002\u5f53\u7136PHP\u5b98\u65b9\u4e5f\u77e5\u9053PHP\u6700\u5927\u7684\u77ed\u677f\uff0c\u4e8e\u662f\u63a8\u51fa\u4e86PHP7\u9879\u76ee\uff0c\u4e3b\u8981\u662f\u91cd\u6784\u4e86Zend Engine\u5f15\u64ce\u3002<\/p>\n
PHP7\u6700\u663e\u8457\u7684\u53d8\u5316\u5c31\u662f\u6027\u80fd\u7684\u6781\u5927\u63d0\u5347\uff0c\u5df2\u63a5\u8fd1Facebook\u5f00\u53d1\u7684PHP\u6267\u884c\u5f15\u64ceHHVM\u3002\u5728WordPress\u57fa\u51c6\u6027\u80fd\u6d4b\u8bd5\u4e2d\uff0c\u901f\u5ea6\u6bd45.6\u7248\u672c\u8981\u5feb2~3\u500d\uff0c\u5927\u5927\u51cf\u5c11\u4e86\u5185\u5b58\u5360\u7528\u3002PHP7\u5728\u8bed\u8a00\u4e0a\u4e5f\u6709\u4e00\u4e9b\u53d8\u5316\uff0c\u6bd4\u5982\u6dfb\u52a0\u8fd4\u56de\u7c7b\u578b\u58f0\u660e\u3001\u589e\u52a0\u4e86\u4e00\u4e9b\u65b0\u7684\u4fdd\u7559\u5173\u952e\u5b57\u7b49\u3002\u5728\u5b89\u5168\u65b9\u9762\uff0c\u53bb\u9664\u4e86PHP\u5b89\u5168\u6a21\u5f0f\uff0c\u6dfb\u52a0\u9b54\u672f\u5f15\u53f7\u7b49\u3002\u4e0d\u4ec5\u5982\u6b64\uff0c\u65b0\u7248\u8fd8\u652f\u630164\u4f4d\uff0c\u800c\u4e14\u5305\u542b\u6700\u65b0\u7248Zend\u5f15\u64ce\u3002\u5176\u5b9ePHP7\u7684\u5728\u771f\u5b9e\u573a\u666f\u7684\u6027\u80fd\u786e\u5b9e\u5df2\u7ecf\u548cHHVM\u76f8\u5f53\uff0c\u5728\u4e00\u4e9b\u573a\u666f\u751a\u81f3\u8d85\u8fc7\u4e86HHVM\u3002\u4f46HHVM\u7684\u8fd0\u7ef4\u590d\u6742, \u662f\u591a\u7ebf\u7a0b\u6a21\u578b, \u8fd9\u5c31\u4ee3\u8868\u7740\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u5bfc\u81f4crash\u4e86, \u90a3\u4e48\u6574\u4e2a\u670d\u52a1\u5c31\u6302\u4e86, \u5e76\u4e14\u5b83\u4e0d\u4f1a\u81ea\u52a8\u91cd\u542f\u3002\u53e6\u5916\u5b83\u91c7\u7528JIT, \u90a3\u4e48\u610f\u5473\u7740, \u91cd\u542f\u4ee5\u540e\u8981\u9884\u70ed, \u6ca1\u6709\u9884\u70ed\u7684\u60c5\u51b5\u4e0b, \u6027\u80fd\u8f83\u4e3a\u7cdf\u7cd5\u3002\u5e76\u4e14\u591a\u7ebf\u7a0b\u6a21\u578b\u8c03\u8bd5\u56f0\u96be, \u8fd9\u5bf9\u4e8e\u8ffd\u6c42\u7a33\u5b9a\u6765\u8bf4\u7684Web\u670d\u52a1\u6765\u8bf4, \u662f\u975e\u5e38\u4e0d\u9002\u5408\u7684\u3002<\/p>\n
\u60f3\u4f7f\u7528\u6700\u65b0\u7248PHP\uff0c\u5c31\u9700\u8981\u4f7f\u7528\u5230REMI\u6e90\uff0cRemi repository\u662f\u5305\u542b\u6700\u65b0\u7248\u672cPHP\u548cMySQL\u5305\u7684Linux\u6e90\uff0c\u7531Remi\u63d0\u4f9b\u7ef4\u62a4\u3002\u6709\u4e2a\u8fd9\u4e2a\u6e90\u4e4b\u540e\uff0c\u4f7f\u7528YUM\u5b89\u88c5\u6216\u66f4\u65b0PHP\u3001MySQL\u8f83\u65b0\u7248\u672c\u4e86\u3002<\/p>\n
\u5b89\u88c5\u6700\u65b0\u7684Remi\u6e90\u81ea\u52a8\u5b89\u88c5\u6587\u4ef6<\/p>\n
\r\n# CentOS 6 \/ RHEL 6\r\nyum install http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-6.rpm\r\n\r\n# CentOS 7 \/ RHEL 7\r\nyum install http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-7.rpm\r\n<\/pre>\n\u5b89\u88c5PHP\u76f8\u5173\u7ec4\u4ef6\uff0c\u4e0b\u9762\u63d0\u4f9b\u7684\u662f\u4e00\u4e2a\u751f\u4ea7\u73af\u5883\u4e2d\u53ef\u4ee5\u4f7f\u7528\u7684\u6807\u914d\u5b89\u88c5\u3002<\/p>\n
\r\n$ yum --enablerepo=remi,remi-php70 install\r\nphp \\\r\nphp-cgi \\\r\nphp-cli \\\r\nphp-fpm \\\r\nphp-common \\\r\nphp-devel \\\r\nphp-mysqlnd \\\r\nphp-mysql \\\r\nphp-sqlite3 \\\r\nphp-mbstring \\\r\nphp-msgpack \\\r\nphp-mcrypt \\\r\nphp-bcmath \\\r\nphp-gd \\\r\nphp-xml \\\r\nphp-ldap \\\r\nphp-xmlrpc \\\r\nphp-opcache \\\r\nphp-curl \\\r\nphp-json \\\r\nphp-odbc \\\r\nphp-pdo \\\r\nphp-bz2 \\\r\nphp-xml \\\r\nphp-ftp \\\r\nphp-imap \\\r\nphp-snmp \\\r\nphp-redis \\\r\nphp-memcached\r\n<\/pre>\n\u67e5\u770bPHP\u7248\u672c<\/p>\n
\r\n$ php -v\r\nPHP 7.0.9 (cli) (built: Jul 20 2016 18:08:08) ( NTS )\r\n<\/pre>\n\u542f\u52a8PHP-FPM<\/p>\n
\r\n$ service php-fpm start\r\n<\/pre>\n\u5230\u8fd9\u91cc\uff0cPHP7.0\u5c31\u5b89\u88c5\u5b8c\u6210\u4e86\u3002\u5982\u679c\u9700\u8981\u7528\u5230PHP\u6269\u5c55\u529f\u80fd\uff0c\u5982redis\u3001memcached\u7b49\uff0c\u53ea\u9700\u8981\u4e5f\u4f7f\u7528YUM\u5b89\u88c5\u5373\u53ef\uff0c\u5982\u4e0b\uff1a<\/p>\n
\r\n$ yum --enablerepo=remi,remi-php70 install php-redis php-memcached\r\n<\/pre>\n\u5982\u679c\u5728REMI\u6216EPEL\u6e90\u4e2d\u90fd\u627e\u4e0d\u5230\u4f60\u9700\u8981\u7684\u6269\u5c55\u6a21\u5757\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u624b\u52a8\u7f16\u8bd1\u5b89\u88c5\u4e86\uff0c\u4e5f\u5f88\u7b80\u5355\u3002<\/p>\n
\u53e6\u5916\u67e5\u770bPHP\u6a21\u5757\u4fe1\u606f\u4f7f\u7528php -m\u547d\u4ee4\u3002<\/p>\n
\r\n$ php -m | grep redis\r\nredis\r\n<\/pre>\n\u5b89\u88c5\u4e00\u5957LNMP\u53c2\u8003\uff1aLNMP\u5b89\u88c5\u5305\u90e8\u7f72\u5b9e\u6218\u6216\u8005\u53c2\u8003PHP7.0\u7248\u672c\u7684LNMPZabbix 3.0\u5b89\u88c5\u4f7f\u7528\u8be6\u89e3<\/p>\n
PHP7\u6027\u80fd\u6d4b\u8bd5<\/strong><\/span><\/div>\n\u73af\u5883\uff1a4\u6838 CPU\uff0c\u5185\u5b584G\uff0c\u64cd\u4f5c\u7cfb\u7edfCentos 6.5\u3002<\/p>\n
\u9996\u5148\u8bf4\u4e00\u70b9GCC\u7f16\u8bd1\u5668\u7684\u5efa\u8bae\uff0c\u636e\u9e1f\u54e5\u5efa\u8bae\uff0c\u4f7f\u7528\u65b0\u4e00\u70b9\u7684\u7f16\u8bd1\u5668\uff0c\u63a8\u8350 GCC 4.8\u4ee5\u4e0a\uff0c\u56e0\u4e3a\u53ea\u6709GCC 4.8\u4ee5\u4e0aPHP\u624d\u4f1a\u5f00\u542fGlobal Register for opline and execute_data\u652f\u6301, \u8fd9\u4e2a\u4f1a\u5e26\u67655%\u5de6\u53f3\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n
\u5199\u4e00\u6bb5\u7a0b\u5e8f\uff08\u7f51\u4e0a\u63d0\u4f9b\u7684\u7b80\u5355\u6d4b\u8bd5\u65b9\u6cd5\uff09\uff1a<\/p>\n
\u7b2c\u4e00\u6bb5\uff0c\u751f\u6210\u4e00\u4e2a 60 \u4e07\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u901a\u8fc7\u67e5\u627ekey \u7684\u65b9\u5f0f\uff0c\u6765\u786e\u5b9akey\u662f\u5426\u5b58\u5728\u3002<\/p>\n
\r\n< ?php\r\n$a = array();\r\nfor($i=0;$i<600000;$i++){\r\n $a[$i] = $i;\r\n}\r\n \r\nforeach($a as $i)\r\n{\r\n array_key_exists($i, $a);\r\n}\r\n<\/pre>\n\u9996\u5148\u662fPHP 5.3.17\u7248\u3002<\/p>\n
\r\n[root@localhost test]# time php search_by_key.php \r\nreal 0m0.389s\r\nuser 0m0.337s\r\nsys 0m0.051s\r\n[root@localhost test]# time php search_by_key.php \r\nreal 0m0.378s\r\nuser 0m0.308s\r\nsys 0m0.062s\r\n[root@localhost test]# time php search_by_key.php \r\nreal 0m0.378s\r\nuser 0m0.317s\r\nsys 0m0.061s\r\n<\/pre>\n\u5176\u6b21\u662fPHP 7.0\u7248\u672c\u3002<\/p>\n
\r\n[root@localhost php7]# time php7 search_by_key.php\r\nreal 0m0.082s\r\nuser 0m0.066s\r\nsys 0m0.014s\r\n[root@localhost php7]# time php7 search_by_key.php\r\nreal 0m0.080s\r\nuser 0m0.058s\r\nsys 0m0.021s\r\n[root@localhost php7]# time php7 search_by_key.php\r\nreal 0m0.080s\r\nuser 0m0.053s\r\nsys 0m0.026s`\r\n<\/pre>\n\u54cd\u5e94\u65f6\u95f4\u5728PHP7\u4e0b\u8fd0\u884c\u53d8\u4e3a\u539f\u6765\u76841\/4\u3002<\/p>\n
\u8fd8\u662f\u4e0a\u9762\u7684\u8fd9\u4e2a\u65b9\u5f0f\uff0c\u4e0d\u8fc7\u7531\u4e8e\u901f\u5ea6\u8f83\u6162\uff0c\u6240\u4ee5\u53d8\u6210\u4e86\u4e00\u4e2a60000\u4e2a\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u67e5\u627e\u503c\u3002<\/p>\n
\r\n< ?php\r\n$a = array();\r\nfor($i=0;$i<600000;$i++){\r\n $a[$i] = $i;\r\n}\r\n \r\nforeach($a as $i)\r\n{\r\n array_key_exists($i, $a);\r\n}\r\n\r\n[root@localhost test]# time php search_by_val.php \r\nreal 0m24.296s\r\nuser 0m24.184s\r\nsys 0m0.025s\r\n[root@localhost test]# time php search_by_val.php \r\nreal 0m25.523s\r\nuser 0m25.317s\r\nsys 0m0.026s\r\n[root@localhost test]# time php search_by_val.php \r\nreal 0m26.026s\r\nuser 0m25.478s\r\nsys 0m0.092s\r\n<\/pre>\n\u7b49\u5f85\u7684\u65f6\u95f4\uff0c\u603b\u662f\u89c9\u5f97\u5f88\u6f2b\u957f\uff0c\u4e09\u6b21\u6d4b\u8bd5\uff0c\u82b1\u6389\u4e8675\u79d2\u591a\u3002\u4e0b\u9762\uff0cPHP 7 \u767b\u573a\u4e86\u3002<\/p>\n
\r\n[root@localhost php7]# time php7 search_by_val.php\r\nreal 0m3.362s\r\nuser 0m3.323s\r\nsys 0m0.007s\r\n[root@localhost php7]# time php7 search_by_val.php\r\nreal 0m3.266s\r\nuser 0m3.251s\r\nsys 0m0.004s\r\n[root@localhost php7]# time php7 search_by_val.php\r\nreal 0m3.290s\r\nuser 0m3.275s\r\nsys 0m0.006s\r\n<\/pre>\n\u6709\u6ca1\u6709\uff01\u901f\u5ea6\u6574\u6574\u63d0\u9ad8\u4e86\u5c06\u8fd17\u500d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u63d0\u5230PHP\uff0c\u80af\u5b9a\u4f1a\u6709\u4eba\u8bf4\u8fd9\u662f\u4e16\u754c\u4e0a\u6700\u597d\u7684\u7f16\u7a0b\u8bed\u8a00\u3002\u5355\u8bf4\u6d41\u884c\u7a0b\u5ea6\uff0c\u76ee\u524d\u5168\u7403\u8d85\u8fc781.7%\u7684\u670d\u52a1\u5668\u540e\u7aef\u90fd\u91c7\u7528\u4e86PH […]<\/p>\n","protected":false},"author":1479,"featured_media":11223,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-136139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/136139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=136139"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/136139\/revisions"}],"predecessor-version":[{"id":136558,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/136139\/revisions\/136558"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/11223"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=136139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=136139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=136139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}