I didn't find a Docker image at first that included Apache2 and PHP, so (and for learning purposes) I gathered the information on how I could create a corresponding container myself. This also has the advantage that I can add exactly the packages I need for the CMS I chose, GRAV .
First we create a directory webcontainer
, then we create docker-compose.yml
and Dockerfile
:
mkdir webcontainer
cd webcontainer
bash -c "cat > docker-compose.yml" <<EOF
services:
apache:
restart: always
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:80
volumes:
- /home/jgreven/echo/web/ai-telligence.info:/var/www/html
- ./log:/var/log/apache2
EOF
bash -c "cat > Dockerfile" <<EOF
FROM ubuntu:latest
RUN apt-get update \
&& apt-get install -y \
apache2 \
php8.3 \
php8.3-curl \
php8.3-gd \
php8.3-imagick \
php8.3-mbstring \
php8.3-xml \
php8.3-yaml \
php8.3-zip \
libapache2-mod-php8.3 \
composer \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN a2enmod php8.3
RUN a2enmod rewrite
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
EOF
Of course you have to adjust the paths so they fit your environment. Then you can start the container with the command:
docker compose up --build -d
You can list the running containers with:
docker ps
You can “enter” the running container with:
docker exec -it <CONTAINER-NAME> bash
Of course you have to adjust the name of the container. Completion with the TAB-key works here!