Question

How to upgrade php version from 7.2 to php 7.3 in Ubuntu 16.04?

I have a LEMP stack (Linux, Nginx, MySQL, and PHP) droplet in which i am running a wordpress website. I have got recommendation to upgrade my php version to php 7.3. So, how can i do it in the right way? Also i want to install bcmath and imagick module. It will be very helpful if you describe it in detail step by step. ** Thanks in advance! :)**

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Upgrade to php7.3

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y php7.3

Check php version

php -v

I hope this helps

If you are using nginx after upgrading php you also need to change the directive in nginx’s default configuration file:

vi /etc/nginx/sites-available/default

Find the line:

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

And change it accordingly (7.3 in this example):

fastcgi_pass unix:/run/php/php7.3-fpm.sock;

Otherwise nginx will still use the old version.

additionally to steps from MattIPv4, to enable apache2 to use php7.3 run these:

sudo a2dismod php7.2

a2enmod proxy_fcgi setenvif

a2enconf php7.3-fpm