Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

> haddad_zineddine's avatar

Install php 8.1

hello guys i hope u are doing well ,

in order to install laravel 9 , i tried to install php 8.1 first but i got this error message :

The following packages have unmet dependencies:
php8.1 : Depends: libapache2-mod-php8.1 but it is not installable or
                   php8.1-fpm but it is not installable or
                   php8.1-cgi but it is not installable
E: Unable to correct problems, you have held broken packages.

also when i tried to run sudo apt install php8.1-cli i got this error message :

php8.1-cli : Depends: libpcre2-8-0 (>= 10.38) but 10.36-2 is to be installed
E: Unable to correct problems, you have held broken packages.
0 likes
15 replies
jlrdw's avatar

How did you try to install php 8.1?

jlrdw's avatar

@> Joe try uninstalling old version first, unless you need it as well.

Francis Rwegayura's avatar

@> haddad_zineddine I also tried this but till today I have no clue on how I can solve the problem, can you please help me with this @> haddad_zineddine

Francis Rwegayura's avatar

@> haddad_zineddine What brings you to the error is the

((Depends: libpcre2-8-0 (>= 10.38) but 10.36-2 is to be installed E: Unable to correct problems, you have held broken packages.))

So install libpcre2-8-0=10.40-1 from this official debian packages site https://packages.debian.org/sid/amd64/libpcre2-8-0/download There after try installing php8.1 again then wait for the results.

apt show libpcre2-8-0
Package: libpcre2-8-0
Version: 10.40-1
Status: install ok installed
Priority: optional
Section: libs
Source: pcre2
Maintainer: Matthew Vernon <[email protected]>
Installed-Size: 702 kB
Depends: libc6 (>= 2.14)
Homepage: https://pcre.org/
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: New Perl Compatible Regular Expression Library- 8 bit runtime files
 This is PCRE2, the new implementation of PCRE, a library of functions
 to support regular expressions whose syntax and semantics are as
 close as possible to those of the Perl 5 language. New projects
 should use this library in preference to the older library,
 confusingly called pcre3 in Debian.
 .
 This package contains the 8 bit runtime library, which operates on
 ASCII and UTF-8 input.

php --version
PHP 8.1.6 (cli) (built: May 17 2022 16:48:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
Francis Rwegayura's avatar

@> haddad_zineddine I have a successful solution to this, Please follow these steps:

Open this link (https://packages.debian.org/sid/amd64/libpcre2-8-0/download) then find the region you are and download the debian package for installation. After installing the libpcre2-8-0 version 10.40-1 or later, Run sudo apt install php8.1 There after you will be ready to go with php8.1 and laravel 9... as an alternative to laravel-sail in parrot OS

1 like
Francis Rwegayura's avatar

@> haddad_zineddine which region are you in?? as in, in what country are you located at???

Gaurav.chaurasiya's avatar

Hi friends After so many RnD I found this article and its working fine for me

1st we have to remove the "libapache2-mod-php8.1"

and after that sudo aptitude update sudo aptitude -y install libapache2-mod-php8.1

user this link

installati.one/ubuntu/22.04/libapache2-mod-php8.1/

1 like
SimonAngatia's avatar

I tried many options but they didn't work. The option that worked was installing aptitude and using it to install those packages.

sudo apt-get update
sudo apt-get install aptitude
//install packages
sudo aptitude install libapache2-mod-php8.1 php8.1-fpm php8.1-cgi


Please or to participate in this conversation.