How do I enable PHP 7.3 in Apache2

I followed the instructions in https://idroot.us/install-php-7-3-ubuntu-18-04/ to install PHP 7.3 and then, as instructed, ran

a2enmod proxy_fcgi setenvif

a2enconf php7.3-fpm

to enable it in Apache2.

systemctl status php7.3-fpm

confirms that php7.3 is installed and running and I did restart Apache2 using

systemctl restart apache2

php -v reports PHP 7.3.6-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:06:48) ( NTS )

However, phpinfo(); reports PHP 7.2: PHP Version 7.2.17-0ubuntu0.18.04.1

What have I missed? Any guidance would be appreciated as I'm totally new to Ubuntu.

Thanks


Solution 1:

You have to disable the older version of PHP (a2dismod [oldversion]) and then enable the new version with

sudo a2enmod php7.3

Then restart apache2

Solution 2:

In my case I had to do the following

sudo add-apt-repository ppa:ondrej/php

sudo apt-get install php7.3 php7.3-cli php7.3-mysql php7.3-gd php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-common php7.3-curl php7.3-mbstring php7.3-xml php7.3-bcmath php7.3-bz2 php7.3-intl php7.3-json php7.3-readline php7.3-zip

sudo apt install libapache2-mod-php7.3

sudo a2enmod php7.3

After install apache still used php7.0, so I had to remove 7.0 configs manually:

cd /etc/apache2/mods-enabled
ls -la | grep php
sudo rm php7.0.conf

And finally

sudo service apache2 restart