docker的官方php镜像php:5.4-apache配置xdebug-gd-mysql-mysqli

Docker-php-apache-xdebug-gd-mysql-mysqli历坑记
可以直接看最后的小结部分,之前的是做个记录…

缘起

PHP & MySQL范例精解,创建、修改、重用一书中,代码用到的mysql_connect在5.5版本已经废弃,故改用php:5.4-apache

添加xdebug

找xdebug的对应版本号

找对应版本号失败经验

  1. ❌网上介绍的到xdebug站点,用phpinfo()的信息贴进去,发现,对5.6,5.4,5.3的都试过,都显示不支持.

  2. pecl search xdebug

    # pecl search xdebug
    Package Stable/(Latest) Local
    xdebug  2.9.4 (stable)        Provides functions for function traces and profiling
    

    尝试2.9.4结果:

    pecl/xdebug requires PHP (version >= 7.1.0), installed version is 5.4.45
    

✅最终,在https://github.com/xdebug/xdebug/tree/xdebug_2_4发现下面这句

Restrict Xdebug 2.4 to PHP >= 5.4 and PHP < 7.1

打出镜像

Dockerfile

FROM php:5.4-apache
COPY Dockerfile /
RUN pecl channel-update pecl.php.net && \
        pecl install xdebug-2.4.1 && \
        docker-php-ext-enable xdebug && \
        mv /Dockerfile /Dockerfile.php-5.4-apache-xdebug
# mkdir Dockerfile.php-5.4-apache-xdebug && cd Dockerfile.php-5.4-apache-xdebug
# docker build -t php-5.4-apache-xdebug .

终于可以打出镜像

初步添加mlocate和gd

查看版本及替换源

查看容器里的debian版本是jessie

# cat /etc/apt/sources.list
deb http://httpredir.debian.org/debian jessie main
deb http://httpredir.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main

替换源为阿里的

mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://mirrors.aliyun.com/debian jessie main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.aliyun.com/debian jessie main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.aliyun.com/debian jessie-updates main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.aliyun.com/debian jessie-updates main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list &&\

尝试Dockerfile失败:

这个可以跳过不看,作个记录…

FROM php-5.4-apache-xdebug
COPY Dockerfile /
RUN mv /Dockerfile /Dockerfile.php-5.4-apache-xdebug-mlocate-gd && \
mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.aliyun.com/debian jessie main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb-src http://mirrors.aliyun.com/debian jessie main contrib non-free" >> /etc/apt/sources.list &&\
echo "deb http://mirrors.aliyun.com/debian jess
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值