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.



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

  • 1
    a2dismod php7.2 got rid of 7.2 and 7.3 appeared but 'a2enmod php7.3' failed, saying ERROR: Module php7.3 does not exist!. While that means I have a working 7.3 it looks like I have still messed up somewhere. How do I totally remove 7.2 (once I am happy 7.3 is fine)?
    – Dave R
    Jun 2 '19 at 21:32
  • 2
    That means you haven't installed libapache2-mod-php7.3 yet.
    – Eric Mintz
    Jun 2 '19 at 22:13
  • Be aware that you've got to get 7.3 working in apache, AND mysql (probably 5.7.27 as of this post) working in php 7.3 - so the php7.3-mysql package is very important. When you do phpinfo() from the browser, make sure it's showing mysql support as well. Sep 10 '19 at 17:02

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
  • Terrible idea, don't add a ppa for php. Also don't rm the conf files, the command is a2dismod.
    – Nobody
    Sep 16 '19 at 15:56
  • @Nobody Why is it a terrible idea to add a PPA for PHP?
    – slhck
    Oct 11 '19 at 13:34
  • @slhck Because PPAs lower stability and security and in this case for no benefit at all.
    – Nobody
    Oct 12 '19 at 11:21
  • @Nobody The benefit is that you get PHP 7.3 instead of 7.2. The PPA seems to be used a lot, so if anything you have more eyes on it.
    – slhck
    Oct 12 '19 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.