Install Xdebug from sources in Dockerfile, docker

Tested on: docker php:5.6.40-fpm

If you need Xdebug version compatibile with older php versions and you can’t do it by PECL.

Download sources to .docker dir e.g. .docker/xdebug-2.5.5.tgz

In Dockerfile:

# Xdebug install from sources
RUN echo \
    && mkdir /usr/local/lib/xdebug
COPY .docker/xdebug-2.5.5.tgz /usr/local/lib/xdebug/xdebug-2.5.5.tgz
RUN echo \
    && cd /usr/local/lib/xdebug/ && tar zxvf xdebug-2.5.5.tgz \
    && cd /usr/local/lib/xdebug/xdebug-2.5.5 \
    && phpize \
    && ./configure --enable-xdebug \
    && make \
    && make install

Configure SSL/HTTPS on Apache2 with OpenSSL on localhost/docker/vm etc.

sudo apt-get update
sudo apt-get install -y openssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/certs/privkey.pem -out /etc/ssl/certs/fullchain.pem -subj "/C=PL/ST=mazowieckie/L=Warszawa/O=NAZWA FIRMY/OU=NAZWA JEDNOSTKI/CN=localhost"
sudo a2enmod ssl

Add to 000-default.conf

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    # ProxyPassMatch ^/(.*\.php)$ fcgi://php:9000/var/www/html/$1 # If we use FPM

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/fullchain.pem
    SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Handle docker error: Couldn’t connect to Docker daemon

Issue:

ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The Docker daemon always runs as the root user. If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

sudo groupadd docker
sudo usermod -aG docker $USER

Now log out and log in or reboot to preserve changes.