Ubuntu 16.04 安装 Apache, MySQL, PHP7.2

先更新系统

sudo apt update

安装PHP

通过修改PPA源的方式来安装

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 a2dismod php5

sudo a2enmod php7.2

安装php扩展

sudo apt-get install php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-intl

php -v 查看版本

安装其他扩展

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

也可以使用同一个ppa源 安装 7.0、7.1

sudo apt-get install -y php7.0

sudo apt-get install -y php7.1

执行sudo apt-get upgrade或者install时出现E: Sub-process /usr/bin/dpkg returned an error code (1)错误解决办法

执行以下命令

$ sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/

$ sudo mkdir /var/lib/dpkg/info/

$ sudo apt-get update

安装Apache2

sudo apt install apache2

安装MySQL

sudo apt install mysql-server php7.2-mysql
 sudo apt-get install mysql-client
 mysql_secure_installation

安装phpmyadmin

sudo apt-get install phpmyadmin
sudo apt-get install php-mbstring
sudo apt-get install php-gettext
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

配置phpmyadmin

1 nano /etc/php/7.0/apache2/php.ini

display_errors = On(显示错误日志,出现两次,都要改,不然无效)
extension=php_mbstring.dll (开启mbstring)

上一篇:Ubuntu 16.04 安装Mysql 5.7 踩坑小记


下一篇:【spring boot】application.properties官方完整文档【参考使用】