Cómo actualizar PHP en Ubuntu

En este artículo, le explicaré cómo puede actualizar su versión actual de PHP en Ubuntu sin perder ninguna funcionalidad.

En primer lugar tienes que añadir este repositorio PHP PPA.

add-apt-repository ppa:ondrej/php

You can check the repository you just added by listing this directory.

ls -lrt /etc/apt/sources.list.d

Once you have added the repository check the PHP version you are currently running with this command.

php -v

If for example you have PHP version 7.3 and you’d like to install PHP 7.4, then you should run this single command.

apt install $(apt list --installed | grep php7.3 | cut -d '/' -f1 | sed -e 's/7.3/7.4/g')

This command will automatically install all the required packages (the same ones as you had before) so that you don’t lose any package during the upgrade.

Now disable PHP 7.3 and enable PHP 7.4 module.

a2dismod php7.3
a2enmod php7.4

Once the new version is added, I recommend that you restart Apache.

service apache2 restart

And now you can check again your PHP version. It should be updated.

I hope this helped 🙂

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *