With Apache - PHP - MySQL - PhpMyAdmin - Mailhog
| localhost | phpmyadmin | mailhog |
|---|---|---|
| Server | Database | |
![]() |
![]() |
![]() |
| http://localhost:8002 | http://localhost:8003 | http://localhost:7025 |
You need to have Docker installed on your server to proceed using this PHP environment.
Donwload Docker: https://www.docker.com/
The following four separate service containers will be used:
-
phpservice running PHP 8. (Created from Dockerfile) -
apacheservice running Apache2. (Created from Dockerfile) -
dbservice running MySQL. (Created from Image) -
phpmyadminservice running PhpMyAdmin. (Created from Image) -
mailhogservice running Mailhog. (Created from Dockerfile and Image)
Get the project per git or donwload it from github https://github.com/prod3v3loper/docker/releases.
$ git clone https://github.com/prod3v3loper/docker.gitBefore you start for the first time
Set the MySQL environment variables creating a .env file, with:
/* Default dont touch is defined in docker-compose.yml */
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
/* Use what you want here */
DB_DATABASE=databasename
DB_USERNAME=username
DB_PASSWORD=passwordWhen the build is finished, you can run the environment in background mode with:
$ docker-compose up -dStart with when mysql or other not running to log the states:
$ docker-compose upRebuild to recreate the images and settings on startup:
$ docker-compose up -d --no-deps --buildRecreate the db on startup:
$ docker-compose up --force-recreate dbTo shut down your Docker Compose environment and remove all of its containers, networks, and volumes, run:
$ docker-compose downNow go to your browser and access your serverβs domain name or IP address on port 8002.
| localhost | phpmyadmin | mailhog |
|---|---|---|
| Server machine | PhpMyAdmin storage | Mail testing |
| http://localhost:8002 | http://localhost:8003 | http://localhost:7025 |
Defined in
docker-compose.yml
To show information about the state of your active services (e.g. CONTAINER-ID), run:
$ docker psIf the container is running but not showing up with just docker ps, extend it with the -a parameter:
$ docker ps -aGo direct in the container per bash:
$ docker exec -it <CONTAINER-ID OR NAME> bashInside the container you can run PHP
$ php -mOr run composer
$ composer install If you not in a bash environment, get bash in this project and run:
$ docker exec -it <CONTAINER-ID OR NAME> /bin/bashCopy files from container
$ docker cp <CONTAINER-ID OR NAME>:/usr/local/etc/php phpYou can use the docker exec command to execute commands in the service containers, without going into the container:
$ docker exec <CONTAINER-ID OR NAME> ls -l$ docker exec <CONTAINER-ID OR NAME> composer install$ docker exec <CONTAINER-ID OR NAME> php -mBuild the app image to upload in dockerhub:
$ docker build <CONTAINER-ID OR NAME>Call the URLs to test database and mail.
| Database | |
|---|---|
| Check after that in phpmyadmin | Check after that mailhog |
| http://localhost:8002/dbtest/ | http://localhost:8002/mailtest/ |
Please use the issue tab to request a:
- Bug
- Feature
Choose template and report a bug or feature you want issues.
Please read the contributing to contribute.
Please use the Security section for privately reporting a vulnerability.
PROD3V3LOPER - All works


