skip to Main Content

I am trying to install the phpize on Ubuntu 20.04 PHP 8.1

I tried following commands but no luck

  1. sudo apt-get install php8.0-dev
E: Unable to locate package php8.0-dev
E: Couldn't find any package by glob 'php8.0-dev'
E: Couldn't find any package by regex 'php8.0-dev'
  1. sudo apt-get install php-dev
 php-dev : Depends: php7.4-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
  1. sudo apt-get install php8.1-dev
E: Couldn't find any package by glob 'php8.1-dev'
E: Couldn't find any package by regex 'php8.1-dev'

2

Answers


  1. sudo apt update && sudo apt install -y software-properties-common 
    sudo add-apt-repository ppa:ondrej/php 
    sudo apt update
    

    and then try

    Login or Signup to reply.
  2. You might find the following also appropriate:

    #!/bin/sh
    # To add this repository please do:
    
    if [ "$(whoami)" != "root" ]; then
        SUDO=sudo
    fi
    
    ${SUDO} apt-get update
    ${SUDO} apt-get -y install apt-transport-https lsb-release ca-certificates curl
    ${SUDO} curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
    ${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
    ${SUDO} apt-get update
    

    Source: https://packages.sury.org/php/README.txt


    For example, a Dockerfile:

    FROM debian:stable
    
    # ...
    
    # PHP 8.1
    # --------------------------------
    # Related: https://packages.sury.org/php/README.txt
    
    RUN 
        DEBIAN_FRONTEND=noninteractive 
            apt-get update && 
            apt-get full-upgrade && 
            apt-get clean;
    
    RUN 
        DEBIAN_FRONTEND='noninteractive' 
            apt-get update && 
            apt-get install -y -- 
                apt-transport-https lsb-release ca-certificates curl && 
            curl -sSLo '/usr/share/keyrings/deb.sury.org-php.gpg' 'https://packages.sury.org/php/apt.gpg' && 
            printf -- '%sn' "deb [signed-by=/usr/share/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 && 
            apt-get install -y 
                php8.1-fpm php8.1-bcmath php8.1-curl php8.1-mbstring php8.1-pdo php8.1-mysql php8.1-xml && 
            apt-get clean;
    
    # ...
    
    ENTRYPOINT [ "./entrypoint.sh" ]
    CMD [ "php-fpm8.1" ]
    

    Just in case, currently, the main difference between relatively common Debian and Alpine Linux PHP extension installations is that the latter builds extensions (i.e. make, docker-php-extension-installer) and the former – uses pre-compiled binaries (e.g. Bullseye/amd64).

    Alpine versions are currently mostly used in the official PHP Docker registry, yet the above PPA for PHP (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1) (ppa:ondrej/php) mostly by Ondřej Surý is quite known and trusted.

    I am a Debian Developer since year 2000, and I have been packaging PHP for Debian since PHP 5. That means the official packages in Debian and Ubuntu are either my work or they are based on my work. The PHP packages in my Ubuntu PPA and Debian DPA matches the official packages in Debian. Basically I am saying that you can’t get any closer than that.

    Source: https://deb.sury.org

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search