1. Add PPA ondrej/php
sudo add-apt-repository ppa:ondrej/php
sudo apt update
2. Current PHP packages
dpkg -l | grep php | tee packages.txt
3. Install PHP 7.2
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
If you are using Apache with prefork
MPM (type apachectl -V
to see the MPM used), you’d need to install libapache2-mod-php7.2
instead of php7.2-fpm
.
4. Install additional modules
Take a look at the packages.txt
file we created at step #2
5. Web server configuration
Apache with php-fpm
a2disconf php7.1-fpm
a2enconf php7.2
Apache with mod_php
a2dismod php7.1 (or your current version)
a2enmod php7.2
6. Remove old versions
sudo apt purge php7.1*
Source: https://ayesh.me/Ubuntu-PHP-7.2