linux 安装 php 任意版本


sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

For PHP 5.5.36

sudo apt-get install php5.5

For PHP 5.6.22

sudo apt-get install php5.6

To verify the version installed, run the following command:

sudo php -v

If you want to remove PHP installed, then run the following commands:

sudo apt-get update
sudo apt-get purge php5-common -y
sudo apt-get --purge autoremove -y


# 安装yum-utils并启用EPEL存储库
yum install epel-release yum-utils -y
# 下载并安装remirepo
yum install
# 配置PHP 7.0存储库
yum-config-manager --enable remi-php70
# 配置PHP 7.1存储库
yum-config-manager --enable remi-php71
# 配置PHP 7.2存储库
yum-config-manager --enable remi-php72
# 配置PHP 7.3存储库
yum-config-manager --enable remi-php73
# 安装PHP以及依赖项
yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql -y
# 搜索所有PHP模块
yum search php | more


sudo yum install -y php php-fpm php-zip php-gd php-pdo php-pdo_mysql php-xml php-mbstring php-ctype php-json php-openssl
sudo systemctl enable php-fpm