ubuntu
sudo add-apt-repository ppa:ondrej/php # Press enter to confirm.
sudo apt-get update
Debian
sudo apt install apt-transport-https lsb-release
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg # Download the signing key
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list.
sudo apt update
Instalar
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-common php7.4-cli php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-readline php7.4-zip php7.4-mysql php7.4-dom php7.4-ldap php7.4-bcmath php7.4-bz2 php7.4-intl php7.4-mbstring php7.4-apc php7.4-apcu php7.4-igbinary php7.4-imagick php7.4-odbc php7.4-pgsql php7.4-readline php7.4-redis php7.4-sqlite3 php7.4-xml php7.4-xsl php7.4-OPcache php7.4-gmp -y
Habilitar módulo
sudo a2enmod php7.4
Eliminar versiones anteriores
sudo apt purge php7.3 libapache2-mod-php7.3 # For removing PHP 7.3
sudo apt purge php7.2 libapache2-mod-php7.2 # For removing PHP 7.2
sudo apt purge php7.1 libapache2-mod-php7.1 # For removing PHP 7.1
sudo apt purge php7.0 libapache2-mod-php7.0 # For removing PHP 7.0
Reiniciar servidor
service apache2 reload
verificar versión
php -v