{"id":1177,"date":"2024-07-24T17:16:10","date_gmt":"2024-07-24T09:16:10","guid":{"rendered":"https:\/\/www.sulabs.net\/?p=1177"},"modified":"2024-07-25T19:41:45","modified_gmt":"2024-07-25T11:41:45","slug":"%e5%9c%a8rocky-linux-9-%e4%b8%8a%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85php-7-4-32","status":"publish","type":"post","link":"https:\/\/www.sulabs.net\/?p=1177","title":{"rendered":"Rocky Linux 9 \u4e0a\u7f16\u8bd1\u5b89\u88c5PHP 7.4.33"},"content":{"rendered":"<p>&nbsp; &nbsp; &nbsp;\u56e0\u4e4b\u524d\u7684CentOS8\u7cfb\u7edf\u63d0\u524dEOL\uff0c\u7efc\u5408\u8003\u8651\u5df2\u5c06\u76ee\u524d\u7ef4\u62a4\u5f88\u591a\u670d\u52a1\u5668\u5207\u6362\u5230\u4e86Rocky9,&nbsp; \u5728\u6700\u8fd1\u7684\u4e00\u4e2a\u9879\u76ee\u4e2d\u9700\u8981\u914d\u7f6ePHP 7.4 \u73af\u5883(\u8981\u6c42openssl\u5e93\u7248\u672c\u8981\u5927\u4e8e1.0.1\u5c0f\u4e8e3.0 ) \u4f46 Rocky 9 \u81ea\u5e26\u7684OpenSSL\u5e93 3.0.7 \u4e0d\u53d7\u652f\u6301, \u5728\u6b64\u91cd\u65b0\u6574\u7406\u4e86\u4e0b\u7f16\u8bd1\u914d\u7f6e\u5b89\u88c5\u65b9\u6cd5,\u4e5f\u53ef\u4f9bPHP 5.6 5.5 5.4 5.3 5.2 \u4f4e\u7248\u672c\u5728Rocky9\u4e0a\u7684\u7f16\u8bd1\u5b89\u88c5\u53c2\u8003.<br \/>\n<!--more--><br \/>\n\u539f\u521b\u6587\u7ae0\uff0c\u521b\u4f5c\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904.&nbsp;<\/p>\n<p>OpenSSL \u662fLinux\u7cfb\u7edf\u5e38\u7528\u7684\u4e00\u4e2a\u52a0\u89e3\u5bc6\u5e93\uff0c\u57fa\u672c\u6240\u6709\u6d89\u53ca\u5230\u52a0\u89e3\u5bc6\u7b97\u6cd5\uff0cSSL\uff0cHTTPS \u5e94\u7528\u7684\u8f6f\u4ef6\u90fd\u4f1a\u7528\u5230\u5b83, \u5728 Rocky 9 \u4e2d\u9ed8\u8ba4\u7684OpenSSL \u7248\u672c\u4e3a 3.0.7 \u4ec5\u652f\u6301PHP8.1 \u540e\u7684\u7248\u672c\uff0c\u82e5\u4f7f\u7528\u65e9\u671fPHP\u7248\u672c\u9700\u8981\u642d\u914d\u4f4e\u7248\u672cOpenSSL\uff0c\u5982\u679c\u62ff\u5b83\u53bb\u76f4\u63a5\u53bb\u66ff\u6362\u7cfb\u7edf\u5185\u7f6e\u7248\u672c\u4f1a\u5f15\u8d77\u5f88\u591a\u5e94\u7528\u62a5\u9519\uff0c\u6240\u4ee5\u9700\u8981\u6b63\u786e\u5904\u7406\u7248\u672c\u517c\u5bb9\u95ee\u9898.<\/p>\n<p>\u5728PHP\u53ca\u6269\u5c55\u4e2d\u548copenssl \u4f9d\u8d56\u5173\u7cfb\u5982\u4e0b<br \/>\nPHP 7.0 \u9700\u8981 OpenSSL &gt;= 0.9.8 &lt; 1.2<br \/>\nPHP 7.1-8.0 \u9700\u8981 &gt;= 1.0.1 &lt; 3.0<br \/>\nPHP &gt;= 8.1 \u9700\u8981 &gt;= 1.0.2 &lt; 4.0<br \/>\nPHP\u6269\u5c55curl&nbsp; &nbsp; \u4f9d\u8d56curl\u5e93&nbsp; \u9700openssl\u652f\u6301, \u7f16\u8bd1\u4f7f\u7528\u975e\u7cfb\u7edf\u81ea\u5e26\u7248\u672c<br \/>\nPHP\u6269\u5c55zip&nbsp; &nbsp; &nbsp; \u4f9d\u8d56libzip\u5e93 \u9700openssl\u652f\u6301,\u7f16\u8bd1\u4f7f\u7528\u975e\u7cfb\u7edf\u81ea\u5e26\u7248\u672c<\/p>\n<p>\u7cfb\u7edf\u73af\u5883&nbsp; &nbsp;Rocky Linux 9.4 x86_64 \u6700\u5c0f\u5316\u5b89\u88c5<br \/>\nPHP\u7248\u672c&nbsp; &nbsp;PHP 7.4.32<br \/>\nOpenSSL&nbsp; &nbsp;openssl-3.0.7-27(\u7cfb\u7edf\u81ea\u5e26)&nbsp; &nbsp; openssl-1.1.1w(\u7f16\u8bd1\u5b89\u88c5)<\/p>\n<p>1. \u4e3a\u7cfb\u7edf\u5f00\u542f epel \u548c crb \u6269\u5c55\u6e90 (\u7f16\u8bd1PHP\u4f9d\u8d56\u7684\u5305\u90e8\u5206\u5728\u8fd92\u4e2a\u8f6f\u4ef6\u6e90\u91cc)<br \/>\ndnf install -y epel-release<br \/>\ndnf config-manager --set-enabled crb<\/p>\n<p>2.&nbsp; \u5b89\u88c5\u7f16\u8bd1PHP\u6240\u9700\u7684\u8f6f\u4ef6\u5305.<br \/>\ndnf install -y wget gcc gcc-c++ make cmake perl flex bison autoconf \\<br \/>\nautomake bzip2-devel zlib-devel freetds-devel ncurses-devel \\<br \/>\nlibjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel \\<br \/>\nopenssl-devel libxml2-devel gettext-devel pcre-devel curl-devel \\<br \/>\nopenldap-devel mhash-devel libtool libtool-ltdl-devel gd-devel \\<br \/>\nnet-snmp-devel libicu-devel sqlite-devel oniguruma-devel \\<br \/>\nlibsodium-devel expat-devel libzip-devel c-ares-devel<\/p>\n<p>3. \u7f16\u8bd1\u5b89\u88c5&nbsp; openssl 1.1.1w<br \/>\nwget https:\/\/www.openssl.org\/source\/openssl-1.1.1w.tar.gz<br \/>\n\/\/ \u89e3\u538b\u914d\u7f6e\u5e76\u5b89\u88c5<br \/>\ntar zxf openssl-1.1.1w.tar.gz<br \/>\ncd openssl-1.1.1w<br \/>\n\/\/ \u6ce8: -j4 \u7528\u4e8e\u5e76\u884c\u7f16\u8bd1\u63d0\u901f,\u786e\u8ba4CPU\u6838\u5fc3\u4e0d\u4f4e\u4e8e4\u4e2a, install_sw \u4e0d\u5b89\u88c5man\u6587\u6863<br \/>\n.\/config --prefix=\/usr\/local\/openssl &amp;&amp; make -j4 &amp;&amp; make install_sw<\/p>\n<p>4. \u5411\u7cfb\u7edf\u6dfb\u52a0 openssl 1.1.1&nbsp; \u52a8\u6001\u5e93\u641c\u7d22\u8def\u5f84<br \/>\necho \"\/usr\/local\/openssl\/lib\" &gt;&gt; \/etc\/ld.so.conf.d\/openssl111w.conf &amp;&amp; ldconfig<br \/>\n\/\/ \u68c0\u67e5\u786e\u8ba4\u7ed3\u679c<br \/>\nldconfig -p | grep \"\/usr\/local\/openssl\"<\/p>\n<p>5. \u786e\u8ba4\u7f16\u8bd1\u7684openssl 1.1.1w \u7248\u672c\u4fe1\u606f<br \/>\n\/usr\/local\/openssl\/bin\/openssl version<\/p>\n<p>6. \u7f16\u8bd1\u5b89\u88c5 curl&nbsp; 8.9.0&nbsp; \u4f7f\u7528openssl 1.1.1 \u7248\u672c\uff0cPHP\u7684curl\u6269\u5c55\u9700\u8981\u7528\u5230\u5b83.<br \/>\nwget https:\/\/curl.se\/download\/curl-8.9.0.tar.gz<br \/>\ntar zxf curl-8.9.0.tar.gz<br \/>\ncd curl-8.9.0<br \/>\n\/\/ --with-ssl&nbsp; \u6307\u5b9a\u524d\u9762\u5b89\u88c5\u7684openssl 1.1.1w\u8def\u5f84<br \/>\n\/\/ -disable-ldap&nbsp; \u7981\u7528ldap\u652f\u6301, \u5176\u4f9d\u8d56ldap\u5e93\u5173\u8054openssl3, \u7f16\u8bd1PHP \u65f6ld\u4f1a\u62a5\u9519.<br \/>\n.\/configure --prefix=\/usr\/local\/curl --enable-ares --without-nss --disable-ldaps --disable-ldap --with-ssl=\/usr\/local\/openssl<br \/>\nmake -j4 &amp;&amp; make install<\/p>\n<p>7.&nbsp; \u7f16\u8bd1\u5b89\u88c5libzip 1.10.1 \u4f7f\u7528openssl 1.1.1 \u7248\u672c\uff0cPHP\u7684zip \u6269\u5c55\u9700\u8981\u7528\u5230\u5b83<br \/>\nwget https:\/\/libzip.org\/download\/libzip-1.10.1.tar.gz<br \/>\ntar zxf libzip-1.10.1.tar.gz<br \/>\ncd libzip-1.10.1<br \/>\n\/\/ \u4f7f\u7528CMAKE\u53c2\u6570\u6307\u5b9a\u524d\u9762\u5b89\u88c5\u7684 openssl 1.1.1w \u8def\u5f84<br \/>\ncmake -DCMAKE_INSTALL_PREFIX=\/usr\/local\/libzip \\<br \/>\n-DOPENSSL_ROOT_DIR=\/usr\/local\/openssl \\<br \/>\n-DOPENSSL_LIBRARIES=\/usr\/local\/openssl\/lib \\<br \/>\n-DENABLE_OPENSSL=on -DENABLE_GNUTLS=off \\<br \/>\n-DENABLE_MBEDTLS=off<br \/>\nmake -j4 &amp;&amp; make install<\/p>\n<p>8. \u4e0b\u8f7dPHP 7.4.33 \u5e76\u8fdb\u884c\u914d\u7f6e\u5b89\u88c5<br \/>\nwget https:\/\/www.php.net\/distributions\/php-7.4.33.tar.gz<br \/>\ntar zxf php-7.4.33.tar.gz<br \/>\ncd php-7.4.33<\/p>\n<p>\/\/\u7f16\u8bd1PHP\u524d\u5f15\u5165GCC\u73af\u5883\u53d8\u91cf\uff0c\u4f20\u9012openssl,curl,libzip\u5934\u6587\u4ef6\u548c\u52a8\u6001\u5e93\u8def\u5f84<br \/>\nexport CFLAGS=\"-I\/usr\/local\/openssl\/include -I\/usr\/local\/curl\/include -I\/usr\/local\/libzip\/include\"<br \/>\nexport LIBS=\"-L\/usr\/local\/openssl\/lib -L\/usr\/local\/curl\/lib -L\/usr\/local\/libzip\/lib64\"<\/p>\n<p>\/\/&nbsp; \u914d\u7f6ePHP\u7f16\u8bd1\u53c2\u6570,\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u914d\u7f6e\u9700\u8981\u5f00\u542f\u7684\u6269\u5c55<br \/>\n.\/configure --prefix=\/usr\/local\/php \\<br \/>\n--enable-fpm \\<br \/>\n--sysconfdir=\/usr\/local\/php\/etc \\<br \/>\n--with-config-file-path=\/usr\/local\/php\/etc \\<br \/>\n--enable-mysqlnd \\<br \/>\n--with-mysqli=mysqlnd \\<br \/>\n--with-pdo-mysql=mysqlnd \\<br \/>\n--with-iconv-dir=\/usr\/lib64 \\<br \/>\n--with-openssl \\<br \/>\n--with-expat \\<br \/>\n--with-freetype \\<br \/>\n--with-jpeg \\<br \/>\n--with-webp \\<br \/>\n--with-zlib \\<br \/>\n--with-bz2 \\<br \/>\n--with-curl \\<br \/>\n--with-sodium \\<br \/>\n--with-mhash \\<br \/>\n--with-zip \\<br \/>\n--enable-gd \\<br \/>\n--enable-gd-jis-conv \\<br \/>\n--enable-xml \\<br \/>\n--enable-bcmath \\<br \/>\n--enable-dba \\<br \/>\n--enable-shmop \\<br \/>\n--enable-pcntl \\<br \/>\n--enable-calendar \\<br \/>\n--enable-inline-optimization \\<br \/>\n--enable-gd-jis-conv \\<br \/>\n--enable-mbregex \\<br \/>\n--enable-sysvshm \\<br \/>\n--enable-soap \\<br \/>\n--enable-mbstring \\<br \/>\n--enable-shmop \\<br \/>\n--enable-sysvmsg \\<br \/>\n--enable-sockets \\<br \/>\n--enable-ftp \\<br \/>\n--enable-exif \\<br \/>\n--disable-rpath \\<br \/>\n--without-pear \\<br \/>\n--enable-opcache<\/p>\n<p>\/\/\u5f00\u59cb\u7f16\u8bd1<br \/>\nmake -j4<\/p>\n<p>\/\/\u6ce8\u610f: \u5982\u679c\u4fee\u6539\u4e86php\u7f16\u8bd1\u53c2\u6570,\u5728\u7f16\u8bd1\u7ed3\u675f\u65f6, ld\u94fe\u63a5\u5668\u62a5warning \u8b66\u544a\u4fe1\u606f,\u5173\u8054\u5230<br \/>\nlibssl.so.3 \u548c libcrypto.so.3&nbsp; openssl3 \u5e93\uff0c\u9700\u8981\u518d\u53c2\u8003\u524d\u9762\u6b65\u9aa4\u6765\u89e3\u51b3\u5176\u51b2\u7a81\u4f9d\u8d56.<\/p>\n<p>\/\/\u5b89\u88c5\u5e76\u8fdb\u884c\u914d\u7f6e<br \/>\nmake install<\/p>\n<p>\/\/\u5c06php.ini \u914d\u7f6e\u590d\u5236\u5230 \u5b89\u88c5\u76ee\u5f55\u914d\u7f6e\u6587\u4ef6\u5939\u4e2d<br \/>\ncp php.ini-production \/usr\/local\/php\/etc\/php.ini<\/p>\n<p>\/\/\u94fe\u63a5\u4e00\u4e2aphp\u547d\u4ee4\u884c\u5de5\u5177\u4fbf\u4e8e\u4f7f\u7528,\u53ef\u9009<br \/>\nln -s \/usr\/local\/php\/bin\/php \/usr\/bin\/php<\/p>\n<p>\/\/\u68c0\u67e5 php\u7684openssl\u6269\u5c55\u7248\u672c\u4fe1\u606f, \u8fd4\u56de\u7684\u7248\u672c\u4fe1\u606f\u5747\u4e3a1.1.1w \u5219\u6b63\u786e<br \/>\nphp -i | grep OpenSSL<br \/>\n\u8fd4\u56de<br \/>\nSSL Version =&gt; OpenSSL\/1.1.1w<br \/>\nOpenSSL support =&gt; enabled<br \/>\nOpenSSL Library Version =&gt; OpenSSL 1.1.1w 11 Sep 2023<br \/>\nOpenSSL Header Version =&gt; OpenSSL 1.1.1w 11 Sep 2023<br \/>\nNative OpenSSL support =&gt; enabled<\/p>\n<p>9. \u4e3a\u7f16\u8bd1\u7684PHP\u7684openssl\uff0ccurl \u6269\u5c55\u6307\u5b9a\u6b63\u786e\u7684CA\u8bc1\u4e66\u8def\u5f84, \u4ee5\u4fbf\u6b63\u5e38\u4f7f\u7528.<br \/>\n\u7ea2\u5e3d\u7cfb\u7684CA Root \u8bc1\u4e66\u8def\u5f84\u5728 \/etc\/pki\/tls\/certs\/ca-bundle.crt&nbsp; \u6587\u4ef6\u4e2d<br \/>\n\u7f16\u8f91 php.ini \u6307\u5b9a curl \u548c openssl \u6269\u5c55\u4f7f\u7528\u5176\u8bc1\u4e66<br \/>\nvim \/usr\/local\/php\/etc\/php.ini<br \/>\n\/\/\u627e\u5230\u4ee5\u4e0b\u533a\u6bb5\u5e76\u8fdb\u884c\u4fee\u6539<br \/>\n[curl]<br \/>\ncurl.cainfo = \/etc\/pki\/tls\/certs\/ca-bundle.crt<br \/>\n[openssl]<br \/>\nopenssl.cafile=\/etc\/pki\/tls\/certs\/ca-bundle.crt<\/p>\n<p>10. \u9a8c\u8bc1PHP\u7684openssl\u6269\u5c55\u529f\u80fd\u662f\u5426\u6b63\u5e38.<br \/>\nphp -r 'echo file_get_contents(\"https:\/\/www.baidu.com\");'<br \/>\n\/\/\u7528PHP&nbsp; file_get_contents \u51fd\u6570\u8bbf\u95ee https \u9875\u9762\u5982\u80fd\u6293\u53d6\u5219\u8868\u793aopenssl \u914d\u7f6e\u65e0\u8bef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp;\u56e0\u4e4b\u524d\u7684CentOS8\u7cfb\u7edf\u63d0\u524dEOL\uff0c\u7efc &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/www.sulabs.net\/?p=1177\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[3,4],"tags":[133,132],"class_list":["post-1177","post","type-post","status-publish","format-aside","hentry","category-linux","category-php","tag-php7-4","tag-rocky9","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/1177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1177"}],"version-history":[{"count":10,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/1177\/revisions"}],"predecessor-version":[{"id":1187,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/1177\/revisions\/1187"}],"wp:attachment":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}