创建多版本或者指定PHP版本的运行环境
- 2025-03-19 21:04:00
- 丁国栋
- 原创 36
https://launchpad.net/~ondrej/+archive/ubuntu/php
# https://github.com/oerdnj/deb.sury.org/wiki/Frequently-Asked-Questions#how-to-enable-the-debsuryorg-repository
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt update -y
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
# sudo add-apt-repository ppa:ondrej/apache2
# sudo add-apt-repository ppa:ondrej/nginx
# sudo add-apt-repository ppa:ondrej/nginx-mainline
sudo apt update
sudo apt install php5.6-cli php7.0-cli php7.1-cli php7.2-cli php7.3-cli php7.4-cli php8.0-cli php8.1-cli
update-alternatives --query php
sudo update-alternatives --set php /usr/bin/php7.0
sudo update-alternatives --set php-config /usr/bin/php-config7.0
sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.0
sudo update-alternatives --set phpize /usr/bin/phpize7.0
# How to remove DEB.SURY.ORG / How to downgrade packages to the pristine state?
sudo apt install ppa-purge
sudo ppa-purge ppa:ondrej/php
# 移除软件源
sudo apt-add-repository -r ppa:ondrej/php
sudo add-apt-repository -r ppa:ondrej/php
apt install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-pdo php7.0-mysql php7.0-curl php7.0-gd
sudo vim /etc/apt/sources.list.d/ondrej-ubuntu-php-kinetic.list # jammy << kinetic
# sudo apt install php7.2-fpm php7.2-mbstring php7.2-pdo php7.2-mysql php7.2-curl php7.2-gd php7.2-redis php7.2-xml php7.2-xhprof
sudo apt install php7.2 libapache2-mod-php7.2 php7.2-mbstring php7.2-pdo php7.2-mysql php7.2-curl php7.2-gd php7.2-redis php7.2-xml php7.2-xhprof php7.2-dev
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo a2dismod php8.1
sudo a2enmod php7.2
sudo apache2ctl restart
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mbstring php7.4-pdo php7.4-mysql php7.4-curl php7.4-gd php7.4-redis php7.4-phpdbg php7.4-dev php7.4-xml # php7.4-xdebug
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo a2dismod php8.1
sudo a2enmod php7.4
sudo apache2ctl restart
sudo apt install libapache2-mod-php8.1 php8.1-common php8.1-redis php8.1-mysql php8.1-dev php8.1-curl php8.1-phpdbg php8.1-mbstring php8.1-yaml php8.1-xml php8.1-xdebug php8.1-xhprof php8.1-inotify php8.1-gd
sudo update-alternatives --set php /usr/bin/php8.1
sudo update-alternatives --set php-config /usr/bin/php-config8.1
sudo update-alternatives --set phpdbg /usr/bin/phpdbg8.1
sudo update-alternatives --set phpize /usr/bin/phpize8.1
sudo a2dismod php7.4
sudo a2enmod php8.1
sudo apache2ctl restart
sudo apt install libapache2-mod-php8.2 php8.2-common php8.2-redis php8.2-mysql php8.2-dev php8.2-curl php8.2-phpdbg php8.2-mbstring php8.2-yaml php8.2-xml php8.2-xdebug php8.2-xhprof
sudo apt install php8.2-phpdbg
sudo update-alternatives --set php /usr/bin/php8.2
sudo update-alternatives --set php-config /usr/bin/php-config8.2
sudo update-alternatives --set phpdbg /usr/bin/phpdbg8.2
sudo update-alternatives --set phpize /usr/bin/phpize8.2
发表评论