docker的官方php镜像php:5.6-apache配置xdebug和gd

8 篇文章 0 订阅
2 篇文章 0 订阅
PHP&MySQL范例精解_创建、修改、重用-docker环境搭建-7.docker-php-apache-xdebug-gd

准备Dockerfile,添加xdebug

FROM php:5.6-apache
COPY Dockerfile /
RUN pecl install xdebug-2.5.0 && \
        docker-php-ext-enable xdebug && \
        mv /Dockerfile /Dockerfile.php-5.6-apache-xdebug
# mkdir Dockerfile.php-5.6-apache-xdebug && cd Dockerfile.php-5.6-apache-xdebug
# docker build -t php-5.6-apache-xdebug .

打成镜像php-5.6-apache-xdebug

docker build -t php-5.6-apache-xdebug .

添加mlocate和gd

FROM php-5.6-apache-xdebug
COPY Dockerfile /
RUN mv /Dockerfile /Dockerfile.php-5.6-apache-xdebug-mlocate-gd && \
mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.163.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.163.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list &&\
apt-get update && apt-get install -y mlocate \
                                     libfreetype6-dev \
							         libjpeg62-turbo-dev \
							         libpng-dev && \
docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) gd


# mkdir Dockerfile.php-5.6-apache-xdebug-mlocate-gd && cd Dockerfile.php-5.6-apache-xdebug-mlocate-gd
# docker build -t php-5.6-apache-xdebug-mlocate-gd .

打成镜像

docker run -d --rm \
--name tmp-container \
php-5.6-apache-xdebug-mlocate-gd

配置

xdebug的配置位置

localhost:~ jjkkll$ bash -c "clear && docker exec -it tmp-container sh"
# updatedb
# locate docker-php-ext-xdebug
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

apache的配置位置

/etc/apache2/apache2.conf

添加index.php为默认

docker cp virhuiai-php-fzyz:/etc/apache2/apache2.conf /Volumes/TmpDownload/

添加

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

再拷贝回去

docker cp  /Volumes/TmpDownload/apache2.conf virhuiai-php-fzyz:/etc/apache2/apache2.conf

xdebug在phpstorm可以看之前发的:

https://www.jianshu.com/p/e62866f5657c
https://blog.csdn.net/virhuiai/article/details/105369401?depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2&utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2

运行

docker run -d \
           -p 80:80 \
           --name virhuiai-php-fzyz \
           --net=virhuiai_nw \
           -v /.../fzyz/webapps/:/var/www/html/ \
           -v /.../fzyz/sitedata/:/var/www/sitedata/ \
           -v /.../fzyz/miniphp/:/var/www/miniphp/ \
           -v /.../docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
php-5.6-apache-xdebug-mlocate-gd
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值