Ubuntu 16.04官方源自帶PHP7,因此能夠直接使用apt-get來安裝。php
(1)安裝PHP7以及經常使用擴展。mysql
sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-mbstring php7.0-gd php7.0-json php7.0-cli php7.0-curl libapache2-mod-php7.0
(2)啓用Apache的php7.0模塊,而後重啓Apache。sql
sudo a2enmod php7.0 sudo systemctl restart apache2
(3)啓動php7.0-fpm進程。apache
sudo systemctl start php7.0-fpm
(4)查看php7.0-fpm運行狀態。json
systemctl status php7.0-fpm
(5)測試PHP是否安裝成功php7
php -v
或
php --version