{"id":14847,"date":"2021-03-03T10:23:42","date_gmt":"2021-03-03T02:23:42","guid":{"rendered":"http:\/\/blog.idc.net\/14847\/"},"modified":"2021-03-03T10:23:42","modified_gmt":"2021-03-03T02:23:42","slug":"%e4%b8%80%e6%96%87%e5%bd%bb%e5%ba%95%e8%a7%a3%e5%86%b3ubuntu%e4%b8%8aphp%e7%9a%84%e5%ae%89%e8%a3%85%e4%bb%a5%e5%8f%8a%e7%89%88%e6%9c%ac%e5%88%87%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/14847\/","title":{"rendered":"\u4e00\u6587\u5f7b\u5e95\u89e3\u51b3Ubuntu\u4e0aPHP\u7684\u5b89\u88c5\u4ee5\u53ca\u7248\u672c\u5207\u6362"},"content":{"rendered":"<div class=\"idc_table\">\n<p>Ubuntu\u4e0a\u5b98\u65b9\u7684\u6e90\uff0c\u6bd4\u5982 Ubuntu14.04 \u9ed8\u8ba4\u6e90\u4e2d\u7684\u662f PHP5.6.x\u3001Ubuntu16.04 \u9ed8\u8ba4\u6e90\u4e2d\u7684\u662f PHP7.0.x\uff0c\u90a3\u4e48\u5982\u679c\u60f3\u5728 Ubuntu16.04 \u4e0a\u5b89\u88c5 PHP7.1\uff0cPHP7.2\uff0c\u5e94\u8be5\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u7b54\u6848\u662f\u901a\u8fc7\u7b2c\u4e09\u65b9\u7684\u6e90\u6765\u5b89\u88c5\uff0cppa:ondrej\/php \u662f\u4e00\u4e2a\u6bd4\u8f83\u77e5\u540d\u7684PHP\u6e90\uff08\u76ee\u524d\u7ef4\u62a4php5.6,php7.0,php7.1,php7.2\uff09\u3002\u4e0b\u9762\u5c31\u7528\u8fd9\u4e2a\u6e90\u6765\u5b89\u88c5\u81ea\u5df1\u60f3\u8981\u7684PHP\u7248\u672c\u3002<\/p>\n<p>1.\u901a\u8fc7\u6e90\u5b89\u88c5PHP<\/p>\n<p>sudo add-apt-repository ppa:ondrej\/php<br \/>sudo apt-get update<br \/>sudo apt-get upgrade<br \/>sudo apt-get install php7.1&nbsp; # for PHP 7.1<br \/>sudo apt-get install php7.0&nbsp; # for PHP 7.0<br \/>sudo apt-get install php5.6&nbsp; # for PHP 5.6<\/p>\n<p>2.\u5b89\u88c5\u76f8\u5173\u7248\u672c\u7684PHP\u6a21\u5757<\/p>\n<p>sudo apt-cache search php7*<br \/>...<br \/>php-all-dev - package depending on all supported PHP development packages<br \/>php7.0 - server-side, HTML-embedded scripting language (metapackage)<br \/>php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)<br \/>php7.0-cli - command-line interpreter for the PHP scripting language<br \/>php7.0-common - documentation, examples and common module for PHP<br \/>php7.0-curl - CURL module for PHP<br \/>php7.0-dev - Files for PHP7.0 module development<br \/>php7.0-gd - GD module for PHP<br \/>php7.0-gmp - GMP module for PHP<br \/>...<br \/>...<br \/>...<br \/>php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP<br \/>php7.1-xmlrpc - XMLRPC-EPI module for PHP<br \/>php7.1-zip - Zip module for PHP<br \/>php7.1-opcache - Zend OpCache module for PHP<br \/>php7.1 - server-side, HTML-embedded scripting language (metapackage)<br \/>php7.1-xsl - XSL module for PHP (dummy)<br \/>...<br \/>...<br \/>php7.2-bcmath - Bcmath module for PHP<br \/>php7.2-bz2 - bzip2 module for PHP<br \/>php7.2-cgi - server-side, HTML-embedded scripting language (CGI binary)<br \/>php7.2-cli - command-line interpreter for the PHP scripting language<br \/>php7.2-common - documentation, examples and common module for PHP<br \/>php7.2-curl - CURL module for PHP<br \/>php7.2-dba - DBA module for PHP<\/p>\n<p>3.\u9009\u62e9\u9700\u8981\u7684\u6a21\u5757\uff0c\u5b89\u88c5\u4e4b<\/p>\n<p>sudo apt-get install php7.2-curl php7.2-dev php7.2-gd php7.2-imap php7.2-intl php7.2-mbstring php7.2-mysql php7.2-xml php7.2-zip<\/p>\n<p>4.\u5207\u6362PHP\u7248\u672c<\/p>\n<p>sudo update-alternatives --config php<\/p>\n<p>5.\u8bbe\u7f6eApache\u4e0e\u6b63\u786e\u7684PHP\u7248\u672c\u4e00\u8d77\u8fd0\u884c<\/p>\n<p>sudo a2dismod php7.1&nbsp; &nbsp; &nbsp; &nbsp; # unload the current version<br \/>sudo a2enmod&nbsp; php5.6&nbsp; &nbsp; &nbsp; &nbsp; # load the version you need<br \/>sudo service apache2 restart # restart webserver to apply<\/p>\n<p>\u5230\u6b64\u7ed3\u675f\uff0c\u518d\u4e5f\u4e0d\u7528\u62c5\u5fc3\u5b89\u88c5PHP\uff0c\u5207\u6362PHP\u7248\u672c\u8fd9\u4e9b\u4e8b\u60c5\u5566\u3002<\/p>\n<ul>\n<li>https:\/\/askubuntu.com\/questions\/109404\/how-do-i-install-different-upgrade-or-downgrade-php-version-in-still-supported<\/li>\n<li>https:\/\/tecadmin.net\/install-php-7-on-ubuntu\/<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu\u4e0a\u5b98\u65b9\u7684\u6e90\uff0c\u6bd4\u5982 Ubuntu14.04 \u9ed8\u8ba4\u6e90\u4e2d\u7684\u662f PHP5.6.x\u3001Ubuntu16.04  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-14847","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/14847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=14847"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/14847\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=14847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=14847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=14847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}