{"id":214,"date":"2024-07-15T18:06:48","date_gmt":"2024-07-15T10:06:48","guid":{"rendered":"https:\/\/thereisno.top:4430\/?p=214"},"modified":"2024-07-18T10:24:41","modified_gmt":"2024-07-18T02:24:41","slug":"wordpress-%e5%8d%87%e7%ba%a7php%e8%b8%a9%e5%9d%91%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=214","title":{"rendered":"WordPress\u00a0\u5347\u7ea7php\u8e29\u5751\u65e5\u5fd7"},"content":{"rendered":"\n<p>wordpress\u6536\u5230\u4e86php\u5347\u7ea7\u63d0\u9192\uff0c\u7531\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u6bd4\u8f83\u65e7\uff0c\u5b98\u65b9\u6e90\u5e76\u672a\u63d0\u4f9bphp7.4\u7248\u672c\uff0c\u4ece\u7f51\u4e0a\u641c\u4e86\u597d\u591a\u6559\u7a0b\uff0c\u4e00\u6b65\u6b65\u505a\u4e0b\u6765\uff0c\u8fd8\u662f\u9047\u5230\u4e86\u4e24\u4e2a\u62a5\u9519\u201c<strong>\u60a8\u7684PHP\u4f3c\u4e4e\u6ca1\u6709\u5b89\u88c5\u8fd0\u884cWordPress\u6240\u5fc5\u9700\u7684MySQL\u6269\u5c55<\/strong>\u201d\u3001\u201c<strong>\u6b64\u7ad9\u70b9\u9047\u5230\u4e86\u81f4\u547d\u9519\u8bef\u3002<\/strong>\u201d\uff0c\u5fc3\u60c5\u987f\u65f6\u5954\u6e83\u3002<\/p>\n\n\n\n<p>\u591a\u4e2a\u6559\u7a0b\u52a0\u4e0a\u8e29\u5751\u7ecf\u5386\u6574\u7406\u51fa\u5b89\u88c5\u6559\u7a0b\u5982\u4e0b<\/p>\n\n\n\n<p>\u7b2c 0 \u6b65\uff1a\u7981\u7528\u65e7\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a2dismod php7.0\nservice apache2 restart&nbsp;<\/code><\/pre>\n\n\n\n<p><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6ce8\u610f\u662f restart&nbsp;\u4e0d\u662fstart\u3002\u7b2c\u4e00\u6b21\u5b89\u88c5\u7531\u4e8e\u6ca1\u6709\u6ce8\u610f\u91cd\u542f\u5bfc\u81f4\u5b89\u88c5\u540e\u627e\u4e0d\u5230mysql\u6a21\u5757<\/mark><\/p>\n\n\n\n<p>\u7b2c&nbsp;1&nbsp;\u6b65\uff1a\u6dfb\u52a0&nbsp;PHP PPA&nbsp;\u5b58\u50a8\u5e93<\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u4f7f\u7528&nbsp;PPA&nbsp;\u5b58\u50a8\u5e93\uff0c\u5176\u4e2d\u5305\u542b\u6700\u65b0\u7684&nbsp;PHP&nbsp;\u6784\u5efa\u5305\u3002\u4f46\u8981\u5148\u5b89\u88c5\u4f9d\u8d56\u5305\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt&nbsp;update<br>sudo apt -y install software-properties-common<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0\u5b58\u50a8\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo&nbsp;add-apt-repository&nbsp;ppa:sergey-dryabzhinsky\/php74<br>sudo&nbsp;add-apt-repository&nbsp;ppa:sergey-dryabzhinsky\/php7-modules<br>sudo&nbsp;add-apt-repository&nbsp;ppa:sergey-dryabzhinsky\/backports<br>sudo&nbsp;add-apt-repository&nbsp;ppa:sergey-dryabzhinsky\/packages<\/code><\/pre>\n\n\n\n<p>\u6b65\u9aa42\uff1a\u5728Ubuntu 18.04\/16.04\u4e0a\u5b89\u88c5PHP 7.4<\/p>\n\n\n\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728&nbsp;Ubuntu&nbsp;\u4e0a\u5b89\u88c5&nbsp;PHP 7.4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt -y install php7.4<\/code><\/pre>\n\n\n\n<p>\u68c0\u67e5\u5b89\u88c5\u7684\u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$&nbsp;php&nbsp;-v<br>PHP 7.4.33-SergeyD\/6.1 (cli) ( NTS )<br>Copyright (c) The PHP&nbsp;Group<br>Zend Engine v3.4.0, Copyright (c) Zend Technologies<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\u5305\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php74p-mod-{mysqlnd,bcmath,bz2,gd,intl,mbstring,zip,json}&nbsp;<\/code><\/pre>\n\n\n\n<p><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6ce8\u610f\u5e94\u8be5\u662fmysqlnd\uff0cmysql\u4e0d\u884c\uff0c\u8bb8\u591a\u6587\u6863\u5199\u7684\u662fmysql<\/mark><\/p>\n\n\n\n<p>\u4e0eApache\u76f8\u5173\u7684PHP\u914d\u7f6e\u5b58\u50a8\u5728\/etc\/php74\/apache2\/php.ini<\/p>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u786e\u8ba4PHP\u7248\u672c\uff1a<\/p>\n\n\n\n<p>$&nbsp;php&nbsp;&#8211;version<br>PHP 7.4.33-SergeyD\/6.1 (cli) ( NTS )<br>Copyright (c) The PHP&nbsp;Group<br>Zend Engine v3.4.0, Copyright (c) Zend Technologies<\/p>\n\n\n\n<p>\u5c06&nbsp;PHP 7.4&nbsp;\u4e0e&nbsp;Apache&nbsp;\u7ed3\u5408\u4f7f\u7528<\/p>\n\n\n\n<p>\u5b89\u88c5&nbsp;Apache PHP&nbsp;\u6a21\u5757\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install libapache2-mod-php74<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6267\u884c<\/p>\n\n\n\n<p>a2enmod php74 &amp;&amp; service apache2 restart&nbsp;\u91cd\u8981<br><\/p>\n\n\n\n<p><strong><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u95ee\u9898\u89e3\u51b3\uff1a<\/mark><\/strong><\/p>\n\n\n\n<p>1\u3001\u5b89\u88c5\u5b8c\u6210\u540e\u542f\u52a8apache&nbsp;\u8bbf\u95eewordpress&nbsp;\u62a5\u201c<strong>\u60a8\u7684<\/strong><strong>PHP<\/strong><strong>\u4f3c\u4e4e\u6ca1\u6709\u5b89\u88c5\u8fd0\u884c<\/strong><strong>WordPress<\/strong><strong>\u6240\u5fc5\u9700\u7684<\/strong><strong>MySQL<\/strong><strong>\u6269\u5c55<\/strong>\u201d<\/p>\n\n\n\n<p>php -m \u6ca1\u6709mysqli mysqlnd\u7684\u76f8\u5173\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~# php -m\n&#91;PHP Modules]\nbcmath\nbz2\nCore\nctype\ndate\nfilter\ngd\nhash\niconv\nintl\njson\nlibxml\nmbstring\nmysqli\nmysqlnd\nopenssl\npcntl\npcre\nPDO\npdo_mysql\nReflection\nsession\nshmop\nsockets\nSPL\nstandard\nsysvmsg\nsysvsem\nsysvshm\nzip\nzlib\n&#91;Zend Modules]<\/code><\/pre>\n\n\n\n<p>\u6216\u8005\u5728wordpress&nbsp;\u6839\u76ee\u5f55\u521b\u5efaphpinfo.php&nbsp;\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;? php&nbsp;phpinfo();&nbsp;?&gt;<\/code><\/pre>\n\n\n\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee\u67e5\u770b\u662f\u5426\u6709mysql\u6a21\u5757<\/p>\n\n\n\n<p>\u6309\u4e0a\u9762\u7684\u6b65\u9aa4\u91cd\u88c5\u4e86N\u904d\u8fd8\u662f\u627e\u4e0d\u5230mysql\u6a21\u5757\uff0c\u8003\u8651\u53ef\u80fd\u662f\u5378\u8f7d\u4e0d\u5e72\u51c0\uff0c\u7136\u540e\u4f7f\u7528\u5f7b\u5e95\u5220\u9664\uff08<a href=\"https:\/\/thereisno.top\/?p=211\">\u89c1\u5f7b\u5e95\u5220\u9664php<\/a>\uff09<\/p>\n\n\n\n<p><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6700\u540e\u627e\u5230\u539f\u56e0\u7adf\u7136\u662f\u7531\u4e8e\u6ca1\u6709service apache2 restart\u5bfc\u81f4<\/mark><\/p>\n\n\n\n<p>2\u3001\u89e3\u51b3mysql\u540e\u62a5<strong>\u201c<\/strong><strong>\u6b64\u7ad9\u70b9\u9047\u5230\u4e86\u81f4\u547d\u9519\u8bef\u3002<\/strong><strong>\u201d<\/strong><\/p>\n\n\n\n<p>\u5f00\u542f\u8c03\u8bd5\u6a21\u5f0f<\/p>\n\n\n\n<p>\u4e00\u3001\u5f00\u542f&nbsp;WP Debug&nbsp;\u6a21\u5f0f\u8bbf\u95ee\u4e3b\u9875\u663e\u793a\u9519\u8bef\u8be6\u60c5<strong>Call to undefined function json_decode()<\/strong><\/p>\n\n\n\n<p>\u5f00\u542f&nbsp;DEBUG&nbsp;\u6a21\u5f0f\u663e\u793a\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u6253\u5f00&nbsp;WordPress&nbsp;\u914d\u7f6e\u6587\u4ef6&nbsp;wp-config.php\uff0c\u5c06&nbsp;WP_DEBUG&nbsp;\u8fd9\u4e00\u884c\u4fee\u6539\u4e3a\u5982\u4e0b\u4ee3\u7801\u5373\u53ef\uff1a<\/p>\n\n\n\n<p>\/\/&nbsp;\u5f00\u542fWP_DEBUG\u6a21\u5f0f<\/p>\n\n\n\n<p>define( &#8216;WP_DEBUG&#8217;, true);<\/p>\n\n\n\n<p>\/\/&nbsp;\u5f00\u542fDEBUG\u65e5\u5fd7\uff0c\u4e00\u5b9a\u8981\u8bb0\u5f97\u5173\u95ed\u8fd9\u4e2a\u65e5\u5fd7\u529f\u80fd\u5e76\u6e05\u7406\u8fd9\u4e2a\u65e5\u5fd7\u6587\u4ef6\u54e6\uff0c\u4ea7\u751f\u7684\u65e5\u5fd7\u6587\u4ef6\u5728: \/wp-content\/debug.log<\/p>\n\n\n\n<p>define( &#8216;WP_DEBUG_LOG&#8217;, true);<\/p>\n\n\n\n<p>\/\/&nbsp;\u663e\u793aerrors and warnings<\/p>\n\n\n\n<p>define( &#8216;WP_DEBUG_DISPLAY&#8217;, true);<\/p>\n\n\n\n<p>@ini_set( &#8216;display_errors&#8217;, &#8216;On&#8217;);<\/p>\n\n\n\n<p>\u8c03\u8bd5\u597d\u540e\uff0c\u8bf7\u5343\u4e07\u8bb0\u5f97\u5173\u95ed&nbsp;DEBUG&nbsp;\u6a21\u5f0f\uff0c\u5373\u5c06\u4e0a\u8ff0\u5185\u5bb9\u6539\u56de\uff1a<\/p>\n\n\n\n<p>define( &#8216;WP_DEBUG&#8217;, false);<\/p>\n\n\n\n<p>\u4e8c\u3001\u5f00\u542fjson<\/p>\n\n\n\n<p>\u4fee\u6539\/etc\/php74\/apache2\/php.ini<\/p>\n\n\n\n<p>\u8ffd\u52a0&nbsp;extension=json<\/p>\n\n\n\n<p>\u7136\u540e\u91cd\u542fapache2\uff0c\u6b63\u5e38\u8bbf\u95ee<\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>wordpress\u6536\u5230\u4e86php\u5347\u7ea7\u63d0\u9192\uff0c\u7531\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u6bd4\u8f83\u65e7\uff0c\u5b98\u65b9\u6e90\u5e76\u672a\u63d0\u4f9bphp7.4\u7248\u672c\uff0c\u4ece\u7f51\u4e0a\u641c\u4e86\u597d\u591a\u6559\u7a0b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=214\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cWordPress\u00a0\u5347\u7ea7php\u8e29\u5751\u65e5\u5fd7\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[32],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-wordpress--php"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214"}],"version-history":[{"count":2,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}