在 ubuntu 上安装多个php库

安装多个不同版本的php库

add-apt-repository ppa:ondrej/php
apt update
apt install php5.6 php5.6-fpm php5.6-mysql php5.6-gd php5.6-mbstring php5.6-curl php5.6-soap php5.6-redis php5.6-xml php5.6-apcu php5.6-mcrypt php5.6-cli -y
apt install php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-mbstring php7.4-curl php7.4-soap php7.4-redis php7.4-xml php7.4-apcu php7.4-mcrypt php7.4-cli -y
apt install php8.1 php8.1-fpm php8.1-mysql php8.1-gd php8.1-mbstring php8.1-curl php8.1-soap php8.1-redis php8.1-xml php8.1-apcu php8.1-mcrypt php8.1-cli -y

nginx 配置如下

server {
    listen 80;
    server_name  your.domain;
    server_tokens  off;

    root  /your-web-root;
    index  index.php index.html index.htm;

    location / {
	 try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    location ~ \.php$ {
        fastcgi_pass  unix:/var/run/php/php8.1-fpm.sock;
        include  fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;

    }
}

参考文档:https://os.51cto.com/article/641074.html