If you know Ubuntu, you might ask to yourself why this post even exists. PHP 7.2 is included in the official Ubuntu 18.04 (bionic) repository? Why even bother to make a post about it?

And you’re right - PHP 7.2 is included in the default Ubuntu bionic repository. But some of the PHP packages you might require are not included in the default category.

Packages such as php7.2-zip and php7.2-mbstring are included in the universe category (also referred as distribution component by apt), not in the main category.

And when installing Ubuntu 18.04 Server, the universe category is not enabled by default.

Therefore, to be able to install all php7.2 packages, you need to enable the universe category.

sudo add-apt-repository universe

You can now install all available php7.2 packages.

sudo apt -y install php7.2 php7.2-cli php7.2-gd php7.2-mysql php7.2-pdo php7.2-mbstring php7.2-tokenizer php7.2-bcmath php7.2-xml php7.2-fpm php7.2-curl php7.2-zip

It’s as easy as that.