Ubuntu 18.04 (Apache + php-fpm)

Install apache
apt -y install apache2

Install php-fpm
add-apt-repository universe #add-universe-repository
apt -y update; apt -y upgrade
apt -y install php7.2-fpm

Backup
cp -r /etc/apache2 /root
cp -r /etc/php /root

Configure php-fpm
vim /etc/php/7.2/fpm/pool.d/www.conf

;configure php-fpm to listen using socket or tcp port
;listen = 127.0.0.1:9000
listen = /run/php/php7.2-fpm.sock

Create index file
mkdir /var/www/html

cat > /var/www/html/index.php
<?php phpinfo();?>
ctrl + c

Configure apache
vim /etc/apache2/apache2.conf

#there is 2 way to configure apache for using php-fpm
#first is using FilesMatch
#second is using ProxyPass
#below is the detail

#add this FilesMatch section to apache or virtualhost configuration 
#if you using socket with FilesMatch

<FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
</FilesMatch>

#add this line to apache or virtualhost configuration 
#if you using socket/tcp port with ProxyPass

#ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php/php7.2-fpm.sock|fcgi://var/www/html/
Restart daemon, enable module, and enable configuration

a2dissite 000-default
a2enmod proxy proxy_fcgi setenvif rewrite
a2enconf php7.2-fpm
systemctl restart apache2

Reference : https://wiki.apache.org/httpd/PHP-FPM
Difference between socket and tcp port : https://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket .

Ubuntu 18.04 (Apache + default handler 2.0)

Install php 7.2
apt -y install php7.2 php7.2-common

Enable module php 7.2 for apache
a2enmod php7.2

Configure apache
Just add index.php after DirectoryIndex in apache2.conf
systemctl restart apache2; systemctl enable apache2