LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Friday, February 7, 2025

Installing PHP 7.4 on Latest Debian/Ubuntu

0 comments
PHP 7.4 has reached its end of life, but some applications may still require it for compatibility reasons. If you need to install PHP 7.4 on the latest Debian or Ubuntu systems, follow the steps below. 

Installing PHP 7.4 on Debian

Install essential dependencies:

sudo apt install -y apt-transport-https lsb-release ca-certificates wget

Add the Sury repository:

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Add the PHP repository:

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Update package lists:

sudo apt update

Install PHP 7.4 and required extensions:

sudo apt install -y php7.4 libapache2-mod-php7.4 php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip,cli,fpm,opcache,xml,curl,xsl,soap,json,apcu,imap,xmlrpc}

Installing PHP 7.4 on Ubuntu

Install required dependencies:

sudo apt -y install software-properties-common

Add the Ondřej Surý PPA:

sudo add-apt-repository ppa:ondrej/php

Update package lists:

sudo apt update

Install PHP 7.4 and necessary extensions:

sudo apt install -y php7.4 libapache2-mod-php7.4 php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip,cli,fpm,opcache,xml,curl,xsl,soap,json,apcu,imap,xmlrpc}

Final Steps

After installation, verify the PHP version:

php -v

You should see output confirming PHP 7.4 is installed. If using Apache, restart the service:

sudo systemctl restart apache2

No comments:

Post a Comment