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

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/

添加


    DirectoryIndex index.php index.html

再拷贝回去

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

你可能感兴趣的:(开发,docker,php)