我正在尝试使用Docker和PhpStorm安装Xdebug,但是当我将代码放入Dockerfile中时,会发生错误。
代码:
FROM php:7.1-fpm
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php-xdebug \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && echo "zend_extension=/usr/lib/php/20160303/xdebug.so" > /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.remote_handler=dbgp" >> /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.remote_port=9000" >> /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.remote_autostart=on" >> /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /etc/php/7.1/mods-available/xdebug.ini \
&& echo "xdebug.idekey=docker" >> /etc/php/7.1/mods-available/xdebug.ini
错误:
E: Package 'php-xdebug' has no installation candidate
/bin/sh: 1: cannot create /etc/php/7.1/mods-available/xdebug.ini: Directory nonexistent
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt-get update && apt-get -y --no-install-recommends install php-xdebug && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && echo "zend_extension=/usr/lib/php/20160303/xdebug.so" > /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.remote_enable=on" >> /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.remote_handler=dbgp" >> /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.remote_port=9000" >> /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.remote_autostart=on" >> /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.remote_connect_back=0" >> /etc/php/7.1/mods-available/xdebug.ini && echo "xdebug.idekey=docker" >> /etc/php/7.1/mods-available/xdebug.ini' returned a non-zero code: 2
答案 0 :(得分:1)
图像php:7.1-fpm使用Debian Buster,由于某些原因,我目前无法弄清楚,即使软件包出现在站点中,php-xdebug似乎在仓库中也不可用。 (https://packages.debian.org/buster/php-xdebug)。
我以一种可行的方式重写了Dockerfile,但我将继续检查。
Dockerfile:
FROM php:7.1-fpm
RUN pecl install xdebug
RUN echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so' | tee /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" | tee -a /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_handler=dbgp" | tee -a /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_port=9000" | tee -a /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=on" | tee -a /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back=0" | tee -a /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.idekey=docker" | tee -a /usr/local/etc/php/conf.d/xdebug.ini