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! :)**

Subscribe
Share

Hello. Maybe reboot the server also; sudo reboot, and then sudo apt upgrade


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

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.

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.

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

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

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

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

Hi there @iamhimanshusrivastava,

You should be able to install Php 7.3 by running the following commands:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.3

Installing most of the common Php packages can be achieved by using:

sudo apt-get install php7.3-fpm php7.3-cli php7.3-mysql php7.3-gd php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc

You can then restart Php & Nginx with the following:

sudo systemctl restart nginx.service
sudo systemctl restart php7.3-fpm

Once that is done, nginx should be using php 7.3 - You can verify this by creating a new php file at the root of your website with the following contents:

<?php
phpinfo();

You can then access this file in a browser to confirm that the correct version of php is running.

Hope that helps! - Matt.