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:
-
php
service running PHP 8. (Created from Dockerfile) -
apache
service running Apache2. (Created from Dockerfile) -
db
service running MySQL. (Created from Image) -
phpmyadmin
service running PhpMyAdmin. (Created from Image) -
mailhog
service 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.git
Before 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=password
When the build is finished, you can run the environment in background mode with:
$ docker-compose up -d
Start with when mysql or other not running to log the states:
$ docker-compose up
Rebuild to recreate the images and settings on startup:
$ docker-compose up -d --no-deps --build
Recreate the db on startup:
$ docker-compose up --force-recreate db
To shut down your Docker Compose environment and remove all of its containers, networks, and volumes, run:
$ docker-compose down
Now 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 ps
If the container is running but not showing up with just docker ps, extend it with the -a parameter:
$ docker ps -a
Go direct in the container per bash:
$ docker exec -it <CONTAINER-ID OR NAME> bash
Inside the container you can run PHP
$ php -m
Or 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/bash
Copy files from container
$ docker cp <CONTAINER-ID OR NAME>:/usr/local/etc/php php
You 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 -m
Build 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