參考資料
https://github.com/laradock/laradock/issues/1765#issuecomment-417751894 Allow PHP 7.x and 5.6 side by side
實作
拉兩個目錄的laradock,到時候跑同一個目錄的 info.php ( php_info(); ),相同的 nginx/sites/ 配置
/var/www/html/laradock/ - 跑PHP 7.3
/var/www/html/laradock5/ - 跑PHP 5.6
/var/www/html/laradock5/.env
使用不同的project name,最後會build出的容器名字會是:laradock5_docker-in-docker_1、laradock5_nginx_1、laradock5_php-fpm_1、laradock5_workspace_1
# COMPOSE_PROJECT_NAME=laradock
COMPOSE_PROJECT_NAME=laradock5
使用PHP 5.6
# PHP_VERSION=7.3
PHP_VERSION=5.6
如果你的網路不好,一直裝不成node,可以這樣跳過安裝node
# WORKSPACE_INSTALL_NODE=true
WORKSPACE_INSTALL_NODE=false
如果你的網路不好,一直裝不成yarn,可以這樣跳過安裝yarn
# WORKSPACE_INSTALL_YARN=true
WORKSPACE_INSTALL_YARN=false
避免端口和 /var/www/html/laradock/ (PHP 7.3 )的容器衝突
# WORKSPACE_SSH_PORT=2222
WORKSPACE_SSH_PORT=2226
...
# WORKSPACE_BROWSERSYNC_HOST_PORT=3000
WORKSPACE_BROWSERSYNC_HOST_PORT=3004
# WORKSPACE_BROWSERSYNC_UI_HOST_PORT=3001
WORKSPACE_BROWSERSYNC_UI_HOST_PORT=3005
# WORKSPACE_VUE_CLI_SERVE_HOST_PORT=8080
WORKSPACE_VUE_CLI_SERVE_HOST_PORT=8084
# WORKSPACE_VUE_CLI_UI_HOST_PORT=8001
WORKSPACE_VUE_CLI_UI_HOST_PORT=8005
使用5567端口訪問PHP 5.6容器(PHP 7.3 端口5566)
# NGINX_HOST_HTTP_PORT=80
NGINX_HOST_HTTP_PORT=5567
# NGINX_HOST_HTTPS_PORT=443
NGINX_HOST_HTTPS_PORT=444
# VARNISH_BACKEND_PORT=81
VARNISH_BACKEND_PORT=82
/var/www/html/laradock/ 和 /var/www/html/laradock5/ 都執行
[user@localhost laradock5 ]$ docker-compose up -d nginx workspace
Starting laradock5_docker-in-docker_1 ... done
Starting laradock5_workspace_1 ... done
Starting laradock5_php-fpm_1 ... done
Starting laradock5_nginx_1 ... done
[user@localhost laradock ]$ docker-compose up -d nginx workspace
Starting laradock_docker-in-docker_1 ... done
Recreating laradock_workspace_1 ... done
Recreating laradock_php-fpm_1 ... done
Recreating laradock_nginx_1 ... done
檢查
打開 http://app3.test:5566/info.php (php 7.3) 和 http://app3.test:5567/info.php (php 5.6)
沒有留言:
張貼留言