docker 安装magento2 lnmp环境

讲解docker部署magento2,lamp适当修改也能完成,采用的是ubuntu,如果是centos要注意改变对应的命令。
要在虚拟机中使用Docker部署Magento,可以按照以下步骤进行操作:

一,在虚拟机上安装Docker和Docker Compose:根据虚拟机的操作系统
一键安装Docker
$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Dcloud安装

$ curl -sSL https://get.daocloud.io/docker | sh
Ubuntu搭建Docker
Docker目前支持的最低Ubuntu版本为14.04 LTS,但实际上从稳定性上考虑,推荐使用16.04 LTS或18.0.4 LTS版本,或者20.04LTS版本,并且系统内核越新越好,以支持Docker最新的特性。

官方文档:https://docs.docker.com/engine/install/ubuntu/

更换源(可选,如果更换为清华源,则后面的安装步骤参数需要指定为清华源)
清华大学ubuntu源:
https://mirror.tuna.tsinghua.edu.cn/ubuntu
官方文档:
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
vim /etc/apt/sources.list替换源
更新包索引
sudo apt-get update
手动安装docker
移除系统中可能存在的旧版本的Docker

$ sudo apt-get remove docker docker-engine docker.io containerd runc
安装可以通过https使用仓库的一些相关包

$ sudo apt-get install
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common
添加GPG key清华源:

$ curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
ubuntu源:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
验证指纹

sudo apt-key fingerprint 0EBFCD88
应该得到如下内容:

pub rsa4096 2017-02-22 [SCEA]9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid [ unknown] Docker Release (CE deb)docker@docker.comsub rsa4096 2017-02-22 [S]

添加docker-ce的仓库

清华源:

$ sudo add-apt-repository
“deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu
$(lsb_release -cs) stable”
ubuntu源:

$ echo
“deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装docker

安装前需要再次更新源:

$ sudo apt update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
更换docker镜像源:(可选)

$ sudo vim /etc/docker/daemon.json
{
“registry-mirrors”: [“http://hub-mirror.c.163.com”]
}
启动docker

sudo systemctl start docker

二.创建一个新的目录用于存储Magento的Docker部署文件。

3.在该目录中创建一个名为docker-compose.yml的文件,并使用以下内容:

version: '3'
services:
  web:
    image: nginx:1.8
    ports:
      - "80:80"
    volumes:
      - ./magento:/var/www/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
  php:
    image: php:8.1-fpm
      #build:
      #context: ./
      #dockerfile: Dockerfile  
      #container_name: 'php8'
    volumes:
      - ./magento:/var/www/html
      - /home/一般是自己创建的用户名/docker-c-lnmp/php-config/php.ini:/usr/local/etc/php/php.ini
        #environment:
      #- PHP_EXTENSIONS=bcmath,ctype,curl,dom,fileinfo,gd,hash,iconv,intl,json,libxml,mbstring,openssl,pcre,pdo_mysql,simplexml,soap,sockets,sodium,xmlwriter,xsl,zip
  db:
    image: mysql:8.0
    ports:
      - 3306:3306
    environment
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值