如果以下步驟安裝7.2失敗,可以嘗試安裝7.0版本。
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:ondrej/php && sudo apt-get update
sudo apt-get -y install php7.2
若之前有其他版本PHP,則先卸載
sudo apt-get autoremove php5 php5-fpm php7
安裝常用擴展
sudo -y apt-get install php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-intl
安裝其他擴展(按需安裝)
sudo apt-get install php7.2-gd
sudo apt-get install php7.2-soap
sudo apt-get install php7.2-gmp
sudo apt-get install php7.2-odbc
sudo apt-get install php7.2-pspell
sudo apt-get install php7.2-bcmath
sudo apt-get install php7.2-enchant
sudo apt-get install php7.2-imap
sudo apt-get install php7.2-ldap
sudo apt-get install php7.2-opcache
sudo apt-get install php7.2-readline
sudo apt-get install php7.2-sqlite3
sudo apt-get install php7.2-xmlrpc
sudo apt-get install php7.2-bz2
sudo apt-get install php7.2-interbase
sudo apt-get install php7.2-pgsql
sudo apt-get install php7.2-recode
sudo apt-get install php7.2-sybase
sudo apt-get install php7.2-xsl
sudo apt-get install php7.2-cgi
sudo apt-get install php7.2-dba
sudo apt-get install php7.2-phpdbg
sudo apt-get install php7.2-snmp
sudo apt-get install php7.2-tidy
sudo apt-get install php7.2-zip
sudo apt-get install php7.2-redis
sudo apt-get install php7.2-memcached
sudo apt-get install php7.2-mongodb
sudo apt-get install php7.2-mongo
如果報以下錯誤:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mbstring.so' - /usr/lib/php/20151012/mbstring.so: cannot open shared object file: No such file or directory in Unknown on line 0
則安裝mbstring擴展即可:
sudo apt-get install php7.0-mbstring
參考文章:
1. Deepin 添加 apt 軟件源:
https://blog.csdn.net/one312/article/details/104893204
2. ubuntu14.04 安裝 php7.2:
https://blog.csdn.net/hanzengyi/article/details/83034987
3. deepin/ubuntu apt-get快速安裝的apache、php7.2和nginx和:
php7.2https://blog.csdn.net/ZHANG_TIMI/article/details/89853129