Setting up an Apache + PHP on Ubuntu


If you absolutely need to seperate the reverse-proxy from serving html & php content directly, you may but apache/php inside a container.

This can be done either on an Ubuntu Server host, or inside a container without using a Dockerfile: commit and you’ve got the image.


This image/container will be based on ubuntu:latest or custom/ubuntu.

You probably want to link apache/php to an MySQL/MariaDB container.

Prepare the Apache/PHP image/container

Run the container,

docker ps -a | grep $app
docker run --name $app -h $app \
    -p 80XX:80 -p 84XX:443 \
    -v /data/$app.html:/var/www/html \
    -v /data/$app.sitesenabled:/etc/apache2/sites-enabled \
    [custom/ubuntu](ubuntu) \
docker ps -a | grep $app
docker exec -ti $app bash

Install apache2 & eventually ssl,

apt -y install apache2...
a2enmod ...

If needed, check that you can access the mariadb services,

apt -y install net-tools netcat curl inetutils-ping mariadb-client

cat /etc/hosts
ping -c1 mariadb
nc -z -v mariadb 3306
mysql -uroot -pPASSWORD_HERE -h mariadb --protocol=TCP
show databases;
show tables;

Setup reverse-proxy & ready to go

Setup your reverse-proxy against port 80XX or 84XX.

You can now check the result,