{"id":455,"date":"2019-04-12T23:16:20","date_gmt":"2019-04-12T22:16:20","guid":{"rendered":"http:\/\/blog.chen-hongyi.com\/?p=455"},"modified":"2019-04-12T23:16:20","modified_gmt":"2019-04-12T22:16:20","slug":"%e5%9c%a8unbuntu%e4%b8%8a%e5%ae%89%e8%a3%85%e4%b8%8d%e5%90%8c%e7%89%88%e6%9c%ac%e7%9a%84php%e5%b9%b6%e8%bf%9b%e8%a1%8c%e6%89%8b%e5%8a%a8%e5%88%87%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/chen-hongyi.com\/?p=455","title":{"rendered":"\u5728unbuntu\u4e0a\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684php\u5e76\u8fdb\u884c\u624b\u52a8\u5207\u6362"},"content":{"rendered":"<p>\u5b9e\u9a8c\u7684\u7248\u672c\u662fphp5.6, 7.0. 7.1, 7.2 7.3<\/p>\n<p>\u53c2\u8003\u6559\u7a0b\u3000https:\/\/www.ostechnix.com\/how-to-switch-between-multiple-php-versions-in-ubuntu\/<\/p>\n<p>\u4e3b\u8981\u4f7f\u7528\u4e86update-alternatives\u3000\u8fd9\u4e2a\u5de5\u5177<\/p>\n<p>Switch Between Multiple PHP Versions<br \/>\nTo check the default installed version of PHP, run:<br \/>\n\u3000<br \/>\nYou don\u2019t need to remove PHP7.x or reinstall LAMP stack. You can use both PHP5.x and 7.x versions together.<\/p>\n<p>I assume you didn\u2019t uninstall php5.6 in your system yet. Just in case, you removed it already, you can install it again using a PPA like below.<\/p>\n<p><strong>You can install PHP5.6 from a PPA:<\/strong><\/p>\n<p><code>$ sudo add-apt-repository -y ppa:ondrej\/php<br \/>\n$ sudo apt update<br \/>\n$ sudo apt install php5.6<\/code><br \/>\nSwitch from PHP7.x to PHP5.x<br \/>\nFirst disable PHP7.2 module using command:<\/p>\n<p><code>$ sudo a2dismod php7.2<\/code><\/p>\n<p><code>$ sudo a2enmod php5.6<\/code><br \/>\nSet PHP5.6 as default version:<\/p>\n<p><code>$ sudo update-alternatives --set php \/usr\/bin\/php5.6<\/code><br \/>\nAlternatively, you can run the following command to set which system wide version of PHP you want to use by default.<\/p>\n<p><code>$ sudo update-alternatives --config php<\/code><br \/>\nEnter the selection number to set it as default version or simply press ENTER to keep the current choice.<\/p>\n<p>In case, you have installed other PHP extensions, set them as default as well.<\/p>\n<p><code>$ sudo update-alternatives --set phar \/usr\/bin\/phar5.6<\/code><br \/>\nFinally, restart your Apache web server:<\/p>\n<p><code>$ sudo a2enmod php7.2<br \/>\n$ sudo a2dismod php5.6<br \/>\n$ sudo update-alternatives --set php \/usr\/bin\/php7.2<br \/>\n$ sudo systemctl restart apache2<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u9a8c\u7684\u7248\u672c\u662fphp5.6, 7.0. 7.1, 7.2 7.3 \u53c2\u8003\u6559\u7a0b\u3000htt &hellip; <a href=\"https:\/\/chen-hongyi.com\/?p=455\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-455","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=455"}],"version-history":[{"count":2,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions"}],"predecessor-version":[{"id":457,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions\/457"}],"wp:attachment":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}