Installing PHP 7.4 on Debian 12

sachin
edited January 5 in Linux
Installing PHP 7.4 (By default, Debian 12 install php 8.2 but we are using here php 7.4)
apt-get -y install lsb-release ca-certificates curl
curl -sSLo /etc/apt/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb [signed-by=/etc/apt/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update

Edit nano /etc/apt/preferences.d/stable This is to tell debian to use default Debian repo to install packages.

Package: *
Pin: release o=Debian
Pin-Priority: 900

Edit nano /etc/apt/preferences.d/php This is to tell debian to use sury as repo for php 7.4 and lower and for 8.2, use default repo.

Package: php8.2*
Pin: release o=Debian
Pin-Priority: 900


Package: php-*
Pin: origin "packages.sury.org"
Pin-Priority: 900


Package: php7.4*
Pin: origin "packages.sury.org"
Pin-Priority: 900

Install php

apt-get update
apt install php7.4
apt install php7.4-zip php7.4-curl php7.4-json php7.4-xml php7.4-posix php7.4-mysqlndl php7.4-gd php7.4-process php7.4-curl php7.4-mbstring php7.4-pdo php7.4-pgsql


Tagged:
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!