Here are steps I took to upgrade from PHP 7.0 to 7.4 on Ubuntu 18.04 LTS.
Login as root, otherwise use sudo for all commands.
# use 3rd party ppa repo add-apt-repository ppa:ondrej/php apt -y update apt -y upgrade # install php-core apt install php7.4 php7.4-common php7.4-cli # add all the php extenstions your app needs apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring apt install php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-xml apt install php7.4-readline php7.4-zip php7.4-mysql # I'm using apache prefork MPM, so install it apt install libapache2-mod-php7.4 a2enmod php7.4 # check version. Success! php -v # for good measure, reboot apache systemctl restart apache2.service # Finally, purge the old PHP versions apt purge php7.0 libapache2-mod-php7.0 |
Finally, run update on more time to get all the latest updates.
apt -y update apt -y upgrade apt -y autoremove apt-get --with-new-pkgs upgrade |