debian11 使用apt安装php, 使php多版本共存

sudo apt update 
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' 
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - 

 这里的https://packages.sury.org/php/apt.gpg  key过期了, 需要执行

apt-key adv --fetch-keys 'https://packages.sury.org/php/apt.gpg' > /dev/null 2>&1

apt install php5.6-fpm php7.3-fpm php7.4-fpm php7.4-mbstring php7.4-bz2 php7.4-bcmath php7.4-soap php7.4-gd php7.4-mysql php7.4-xmlrpc php7.4-dev php7.4-curl php7.4-xml php7.4-xsl php7.4-zip php7.4-gmp php7.4-cli php7.4-opcache php7.4-xhprof php7.3-mbstring php7.3-bz2 php7.3-bcmath php7.3-soap php7.3-gd php7.3-mysql php7.3-xmlrpc php7.3-dev php7.3-curl php7.3-xml php7.3-xsl php7.3-zip php7.3-fpm php7.3-gmp php7.3-cli php7.3-opcache php7.3-xhprof php5.6-fpm php5.6-xml php5.6-xmlrpc php5.6-curl php5.6-bz2 php5.6-bcmath php5.6-zip php5.6-xsl php5.6-mysql php5.6-dev php5.6-mbstring php5.6-soap php5.6-gd php5.6-gmp php5.6-cli php5.6-opcache php5.6-mcrypt php5.6-xhprof

安装composer

   38  php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
   39  php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
   40  php composer-setup.php
   41  php -r "unlink('composer-setup.php');"
   42  mv composer.phar /usr/local/bin/composer
   43  chmod +x /usr/local/bin/composer

composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

 

参考:

How To Install PHP (8.2, 7.4 & 5.6) on Debian 11

Apt upgrade failed: GPG error packages.sury.org - #8 by eris - Hestia Control Panel - Discourse

你可能感兴趣的:(php,debian,apt,composer)