• centos7 安装docker及Hyperf


    安装docker:

    用yum源安装-查看是否已安装docker列表:

    yum list installed | grep docker
    

    安装docker:

    yum -y install docker
    

      启动docker

    systemctl start docker
    

     查看docker服务状态

    systemctl status docker
    

      

     自此docker安装完成;

    进入docker后修改时区:

    #修改时区,设置为上海时区
      

    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime	

      或者

    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    

    为docker设置国内阿里云的镜像加速器:

     vi /etc/docker/daemon.json
    

    添加内容如下:

    { 
    "registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"] 
    }
    

    配置文件daemmon,json添加阿里云镜像地址,保存并退出,重启docker服务:

    systemctl restart docker
    sudo systemctl status docker
    sudo docker ps -a -q // 查看所有容器ID
    sudo docker stop $(sudo docker ps -a -q) //  stop停止所有容器
    sudo docker  rm $(sudo docker ps -a -q) //   remove删除所有容器
    

      一次性停止删除容器:

    docker stop $(docker ps -q) & docker rm $(docker ps -aq)
    

      

    docker重启之后,就可以正常拉取镜像了:

    根据Hyperf官方文档安装:

    # 下载并运行 hyperf/hyperf 镜像,并将镜像内的项目目录绑定到宿主机的/mnt/hgfs/www(虚拟机共享目录)
    docker run -v /mnt/hgfs/www/hyperf/:/hyperf-skeleton -p 9501:9501 -it --entrypoint /bin/sh hyperf/hyperf:7.4-alpine-v3.9-cli
    # 镜像容器运行后,在容器内安装 Composer
    wget https://github.com/composer/composer/releases/download/1.8.6/composer.phar

    curl -sS https://getcomposer.org/installer | php
    chmod u+x composer.phar mv composer.phar /usr/local/bin/composer # 将 Composer 镜像设置为阿里云镜像,加速国内下载速度 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer # 通过 Composer 安装 hyperf/hyperf-skeleton 项目 composer create-project hyperf/hyperf-skeleton # 进入安装好的 Hyperf 项目目录 cd hyperf-skeleton # 启动 Hyperf php bin/hyperf.php start

      接下来,就可以在 /mnt/hgfs/www/ 中看到您安装好的代码了。由于 Hyperf 是持久化的 CLI 框架,当您修改完您的代码后,通过 CTRL + C 终止当前启动的进程实例,并重新执行php bin/hyperf.php start启动命令即可。

    热更新/热重载

    git地址下载:https://github.com/ha-ni-cc/hyperf-watch.git

    将'watch'文件放在项目更目录下,在容器中执行:

    启动监听:

    php watch

    启动监听并删除代理类缓存(./runtime/container):

    php watch -c

    退出监听:

    Control + C

    安装 Wsdebug

    git地址 :https://github.com/lamplife/wsdebug

    注意运行docker时同步多个端口:

    docker run -v /mnt/hgfs/www/hlyes_v1/:/hlyes -p9500:9500 -p 9501:9501  -p 9503:9503 -p 9504:9504 -p 9600:9600  -p 9601:9601 -p 9602:9602 -it --entrypoint /bin/sh hyperf/hyperf:7.2-alpine-v3.9-cli
    

     

    指定容器ID

    docker run -v /mnt/hgfs/www/hlyes_v1:/hlyes -p 9600:9600 -p 9604:9604 -p 9601:9601 -p 9500:9500 -it --entrypoint /bin/sh 9e7b52913c1a

      

    进入已启动的容器
    docker exec -it 775c7c9ee1e1 /bin/bash
    

      启动redis

    redis-server &
    

     通过docker-compose启动

    安装

    #curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    
    #chmod +x /usr/local/bin/docker-compose
    #docker-compose --version
    #docker-compose version
    

      编写docker-compose.yml

    version: '2'
    services:
      org:
        build:
          context: ./dev_hyperf
        networks:
          - dev_hyperf
        volumes:
          - /mnt/hgfs/www/hlyes_v1/hlyes_v1_org:/www
        ports:
          - "9601:9601"
      api:
        build:
          context: ./dev_hyperf
        ports:
          - "9500:9500"
        networks:
          - dev_hyperf
        volumes:
          - /mnt/hgfs/www/hlyes_v1/hlyes_v1_api:/www
      center:
        build:
          context: ./dev_hyperf
        ports:
          - "9501:9501"
          - "9604:9604"
        networks:
          - dev_hyperf
        volumes:
          - /mnt/hgfs/www/hlyes_v1/hlyes_v1_center:/www
      cache_server:
        image: "redis:6.0.4"
        networks:
          - dev_hyperf
    networks:
      dev_hyperf:
    

      编写Dockerfile

    docker_composer/dev_hyperf/Dockerfile

    FROM hyperf/hyperf:7.4-alpine-v3.9-cli
    
    WORKDIR /www
    # CMD ["php","bin/hyperf.php","start"]
    CMD php watch
    

      启动运行

    docker-compose -f /mnt/hgfs/www/docker_composer/dev-compose.yml  up
    

      redis 常用命令

    redis-server /usr/local/redis/etc/redis.conf //启动redis
     
    pkill redis  //停止redis
    

      

  • 相关阅读:
    JZOJ 5870 地图
    20190921
    20190919
    SP703 SERVICE
    UVA323 Jury Compromise
    [note]一类位运算求最值问题
    [BZOJ3674]可持久化并查集
    [luogu3359]改造异或树
    [luogu4755]Beautiful Pair
    [BJWC2012]冻结
  • 原文地址:https://www.cnblogs.com/blog-dyn/p/13140160.html
Copyright © 2020-2023  润新知