Background
I come from XAMPP for Windows, which was really easy, but had a design flaw.
I stumbled upon Docker and read that many developers praise its flexibility.
What I need help with
What’s the easiest way to set up apache + php + phpmyadmin such that there is only one php version + config for everything?
My hopes
-
A webserver which I can use for local development and bugfixing.
-
For staging and live, I use a hosting provider.
-
Use this webserver to upgrade old php projects (2014) from php 7.4 to 8.x.
It would also be nice if the webserver could support https, as that makes it easier to migrate software that relies on that between local, staging and live environments.
How far I got
-
I started with a promising YouTube-tutorial on how to make a webserver in Docker.
-
I fetched Docker from Microsoft Store and followed the instructions. However, I ran into issues when I started to actually use that setup.
-
I needed more extensions, which I found with Docker php extension installer.
-
The above research resulted in the following code:
My docker-compose.yaml
services: web: build: ./docker/web volumes: - ./:/var/www/html/ - ./php.ini:/usr/local/etc/php/php.ini ports: - 80:80 db: image: mysql:8.0.43 volumes: - db:/var/lib/mysql/ environment: - MYSQL_ROOT_PASSWORD=[REDACTED] - MYSQL_USER=[REDACTED] - MYSQL_PASSWORD=[REDACTED] - MYSQL_DATABASE=Testserver phpmyadmin: image: phpmyadmin restart: always ports: - 8080:80 environment: - PMA_HOST=db depends_on: - db volumes: db:My Dockerfile
FROM php:7.4.33-apache RUN docker-php-ext-install mysqli # Install php extension installer # Documentation: https://github.com/mlocati/docker-php-extension-installer ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ # Setup desired extensions RUN install-php-extensions\ # First install dependencies imagick\ # Then install extensions bz2\ exif\ gd\ igbinary\ intl\ xdebug\ zipMy php.ini
file_uploads = On memory_limit = 500M upload_max_filesize = 64M post_max_size = 64M -
I then attempted to import a database backup of more than 2 MB in phpmyadmin. This failed.
-
Looking into why, I saw that phpmyadmin was using its image’s own version of php (8.x) and not the one I had configured (7.4.33)
-
This was when I gave up trying to figure this out on my own.
I hope you can help me with this ![]()