php - versions 版本号大全 5.6 - 8.2 并且在docker-compose下的使用

访问量: 395

近期搭建了一个docker环境,看了一下, docker 支持的是 5.6 - 8.2 ,

使用特别简单. 运行这个docker-compose , 就可以了。然后访问对应的端口即可。

docker-compose.yml文件如下:

version: '3'
services:

  php5.4:
    container_name: "php5.4"
    image: php:5.4-apache
    volumes:
      - /d/workspace/docker_folder/php5.4:/var/www/html
    ports:
      - "8054:80"
  php5.5:
    container_name: "php5.5"
    image: php:5.5-apache
    volumes:
      - /d/workspace/docker_folder/php5.5:/var/www/html
    ports:
      - "8055:80"
  php5.6:
    container_name: "php5.6"
    image: php:5.6-apache
    volumes:
      - /d/workspace/docker_folder/php5.6:/var/www/html
    ports:
      - "8056:80"
  php7.0:
    container_name: "php7.0"
    image: php:7.0-apache
    volumes:
      - /d/workspace/docker_folder/php7.0:/var/www/html
    ports:
      - "8070:80"
  php7.1:
    container_name: "php7.1"
    image: php:7.1-apache
    volumes:
      - /d/workspace/docker_folder/php7.1:/var/www/html
    #command: 'mysqld'
    ports:
      - "8071:80"
  php7.2:
    container_name: "php7.2"
    image: php:7.2-apache
    volumes:
      - /d/workspace/docker_folder/php7.2:/var/www/html
    #command: 'mysqld'
    ports:
      - "8072:80"
  php7.3:
    container_name: "php7.3"
    image: php:7.3-apache
    volumes:
      - /d/workspace/docker_folder/php7.3:/var/www/html
    #command: 'mysqld'
    ports:
      - "8073:80"
  php7.4:
    container_name: "php7.4"
    image: php:7.4-apache
    volumes:
      - /d/workspace/docker_folder/php7.4:/var/www/html
    #command: 'mysqld'
    ports:
      - "8074:80"

  php8.0:
    container_name: "php8.0"
    image: php:8.0-apache-bullseye
    volumes:
      - /d/workspace/docker_folder/php8.0:/var/www/html
    ports:
      - "8079:80"
  php8.1:
    container_name: "php8.1"
    image: php:8.1-apache
    volumes:
      - /d/workspace/docker_folder/php8.1:/var/www/html
    ports:
      - "8081:80"
  php8.2:
    container_name: "php8.2"
    image: php:8.2-apache
    volumes:
      - /d/workspace/docker_folder/php8.2:/var/www/html
    ports:
      - "8082:80"

启动 (是不是很壮观)

可以看到大家都运行起来了:

150fd9f21918   php:7.4-apache            "docker-php-entrypoi…"   8 seconds ago   Up 6 seconds   0.0.0.0:8074->80/tcp   php7.4
471a16815c93   php:8.0-apache-bullseye   "docker-php-entrypoi…"   9 seconds ago   Up 6 seconds   0.0.0.0:8079->80/tcp   php8.0
859c66116c44   php:7.0-apache            "docker-php-entrypoi…"   9 seconds ago   Up 6 seconds   0.0.0.0:8070->80/tcp   php7.0
5d611d4f30e5   php:8.2-apache            "docker-php-entrypoi…"   9 seconds ago   Up 5 seconds   0.0.0.0:8082->80/tcp   php8.2
7b8589858419   php:7.2-apache            "docker-php-entrypoi…"   9 seconds ago   Up 6 seconds   0.0.0.0:8072->80/tcp   php7.2
565f0d7061bf   php:8.1-apache            "docker-php-entrypoi…"   9 seconds ago   Up 7 seconds   0.0.0.0:8081->80/tcp   php8.1
274db67aea50   php:5.6-apache            "docker-php-entrypoi…"   9 seconds ago   Up 6 seconds   0.0.0.0:8056->80/tcp   php5.6
a05b53d5cd47   php:7.3-apache            "docker-php-entrypoi…"   9 seconds ago   Up 7 seconds   0.0.0.0:8073->80/tcp   php7.3
e59e394eb6b6   php:7.1-apache            "docker-php-entrypoi…"   9 seconds ago   Up 6 seconds   0.0.0.0:8071->80/tcp   php7.1
d5fb75123d53   php:5.5-apache            "apache2-foreground"     3 minutes ago   Up 7 seconds   0.0.0.0:8055->80/tcp   php5.5
84725e04f63b   php:5.4-apache            "apache2-foreground"     3 minutes ago   Up 7 seconds   0.0.0.0:8054->80/tcp   php5.4

使用

直接访问对应的端口即可。例如上面的php5.4 , 那么就访问 127.0.0.1:8054

先是看到 403 , 原因是 该目录 ( /var/www/html ) 下没有任何文件

我们找到对应的“docker host”的文件夹,

新增任意文件,就可以访问了。

可以看到,php 5.5是个分水岭。2015年就不支持了。

订阅/RSS Feed

Subscribe