PHP&MySQL范例精解_創(chuàng)建、修改倦蚪、重用-docker環(huán)境搭建-7.docker-php-apache-xdebug-gd
準(zhǔn)備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為默認(rèn)
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可以看之前發(fā)的:
http://www.reibang.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
運(yùn)行
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