博客
关于我
docker配置centos+宝塔面板+phpstorm-xdebug记录
阅读量:379 次
发布时间:2019-03-05

本文共 1666 字,大约阅读时间需要 5 分钟。

1 本机环境

我目前运行的是macOS 10.15.7系统,Docker版本为20.10.5。

2 Docker配置CentOS和宝塔面板的步骤

为了在CentOS中配置宝塔面板,我按照以下步骤进行操作:
  • 下载CentOS镜像

    使用命令docker pull ansible/centos7-ansible下载CentOS 7镜像。

  • 新建并运行镜像

    创建一个新的Docker容器,名称为centos7baota,并映射所需的端口:

  • docker run -i -t -d --name centos7baota -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 --privileged=true ansible/centos7-ansible

    这些端口包括80(HTTP)、443(HTTPS)、888(内网访问)、8888(宝塔面板默认端口)。

    1. 进入容器安装宝塔面板
      使用docker exec -it centos7baota /bin/bash进入容器,安装宝塔面板:
    2. yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

      在提示时输入y继续安装。

      1. 配置镜像并提交

        安装完成后,镜像地址会显示为http://60.169.128.90:8888/1e7aad20,可以将其修改为http://localhost:8888/1e7aad20

      2. 安装必要服务

        在宝塔面板中安装nginx、php7.2和mysql5.6等服务,确保环境配置完成后再提交镜像。

      3. 生成并运行新的镜像

        使用docker commit -a "zq" -m "add baota" centos7baota ansible/centos7-ansible/bt提交镜像,并根据新镜像ansible/centos7-ansible/bt运行新的容器:

      4. docker run -i -t -d --name centos7-baota -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 -p 3306:3306 --privileged=true -v ~/Desktop/08-docker/01-www:/www/wwwroot -v ~/Desktop/08-docker/02-mysql:/www/server/data ansible/centos7-ansible/bt
        1. 启动服务并验证
          进入新容器并启动宝塔面板服务:
        2. docker exec -it c7bt /bin/bash  /etc/init.d/bt restart

          开启服务后,宝塔面板可通过http://localhost:8888/1e7aad20访问。

          3 配置PhpStorm远程XDebug调试

          在宝塔面板中完成以下步骤:
        3. 启用XDebug扩展
          在对应的PHP配置文件中启用XDebug远程调试功能:
        4. xdebug.remote_enable = 1  xdebug.remote_handler = "dbgp"  xdebug.remote_host = host.docker.internal

          这些设置允许PhpStorm通过XDebug进行远程调试,host.docker.internal用于指定Docker容器的主机IP。

          1. PhpStorm配置
            在PhpStorm中:
            • 配置远程主机IP为bd.test.com(需在主机hosts文件中添加相应记录)。
            • 使用XDebug作为调试工具。
            1. 添加hosts记录
              在主机上编辑/etc/hosts文件,添加以下内容:
            2. sudo vim /etc/hosts

              添加记录:

              127.0.0.1 bd.test.com

    转载地址:http://gvdwz.baihongyu.com/

    你可能感兴趣的文章
    sum(a.YYSR) over (partition by a.hy_dm) 不需要像group by那样需要分组函数。方便。
    查看>>
    ORCHARD 是什么?
    查看>>
    Struts2中使用Session的两种方法
    查看>>
    Stream API:filter、map和flatMap 的用法
    查看>>
    STM32工作笔记0032---编写跑马灯实验---寄存器版本
    查看>>
    Static--用法介绍
    查看>>
    ssm旅游信息管理系统的设计与实现bus56(程序+开题)
    查看>>
    order by rand()
    查看>>
    SSM(Spring+SpringMvc+Mybatis)整合开发笔记
    查看>>
    ViewHolder的改进写法
    查看>>
    Orderer节点启动报错解决方案:Not bootstrapping because of 3 existing channels
    查看>>
    org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile
    查看>>
    sql查询中 查询字段数据类型 int 与 String 出现问题
    查看>>
    org.apache.commons.beanutils.BasicDynaBean cannot be cast to ...
    查看>>
    org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
    查看>>
    sqlserver学习笔记(三)—— 为数据库添加新的用户
    查看>>
    org.apache.http.conn.HttpHostConnectException: Connection to refused
    查看>>
    org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
    查看>>
    org.apache.ibatis.exceptions.PersistenceException:
    查看>>
    org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
    查看>>