π PHP 7.0 + Apache + MySQL + phpMyAdmin (Dockerized)
This project provides a Dockerized development environment for a legacy PHP 7.0 application with Apache, MySQL 5.7, and phpMyAdmin.
π¦ Services
-
Web (PHP 7.0 + Apache)
- Based on
php:7.0.33-apache - Includes required PHP extensions (
pdo_mysql,mysqli,mbstring,zip,gd, etc.) - Apache runs on port
80 - Custom
php.iniandapacheconfigs included
- Based on
-
Database (MySQL 5.7)
- Root password:
root - Default database:
Mylokal120818 - Default user:
mylokals_user/mylokals_pass - Configurable via
docker/mysql/my.cnf - Data stored in a named volume
mysql_data
- Root password:
-
phpMyAdmin
- Accessible at http://localhost:8081
- Username:
root - Password:
root - Upload limit:
5G
-
π³ Custom Entrypoint Script
We use a custom Docker entrypoint script to ensure Yii runtime and assets directories are writable before Apache starts. This script also fixes permissions for the webservices folder.
- π Purpose
- Ensures runtime and assets folders exist and are writable.
- Applies correct ownership for Apache (www-data).
- Starts Apache with the proper permissions.
- π Purpose
π Project Structure
You can download the complete Docker setup from the link below:
π Docker Setup (ZIP): https://drive.google.com/drive/folders/1O2aOVk_Y7r18J7RF8jruYbUa_hohN43V
After downloading (Docker setup zip.zip) and extracting the ZIP file, you will find the following directory structure:
βββ Dockerfile
βββ docker-compose.yml
βββ docker/
β βββ apache/
β β βββ 000-default.conf
β βββ php/
β β βββ php.ini
β βββ mysql/
β β βββ init/ # Initialization scripts
β β βββ my.cnf # Custom MySQL config
β βββ phpmyadmin/
β | βββ php.ini
β βββ docker/docker-entrypoint.sh
βββ web/
β βββ Mylokal-A # Your application source code
| βββ Services-A # Your application source code
βββ /home/ubuntu54/HDD/Clients/Rakesh # Your application source code (mounted volume)
π§ Usage
1. Build & Start Containers
- For latest version of Docker Compose, use the
docker composecommand: - For older versions of Docker Compose, use the
docker-composecommand:
1.1 To build containers:
- Before running
docker compose build, make sure the required SQL seed file is placed indocker/mysql/init/. Contact Rakesh if you need the latest copy.
docker compose build
or
docker-compose build
1.2 After successful build, run:
docker compose up -d
or
docker-compose up -d
1.3 Access Services
- During the first build the MySQL container imports all seed dataβthis can take 10β20 minutes. Let the process finish before logging in so you donβt run into missing tables or partial data.
App β http://localhost
phpMyAdmin β http://localhost:8081
2. Stop Containers
docker compose down
or
docker-compose down
βοΈ Configuration
Apache
The default DocumentRoot points to /var/www/html. Mount the project source code to the configured host directory:
<Project Root Directory>:/var/www/html
Example: My Cloned project β /web Then it will become:
/web:/var/www/html
Need to update the docker-compose.yml file with the new path inside the web service volumes accordingly.
MySQL
Configurable in docker/mysql/my.cnf. Initialization scripts can be added under docker/mysql/init/.
phpMyAdmin
Config file at docker/phpmyadmin/php.ini.
π³ Tips
-
In Docker Compose, every service you define in docker-compose.yml gets a service name. That service name is then used when:
-
Running commands like docker compose logs, docker compose exec, etc.
-
Naming the default container (Docker usually prefixes it with the project name).
Here:
-
web β is the service name for your PHP 7.0 + Apache container.
-
db β is the service name for MySQL.
-
phpmyadmin β is the service name for phpMyAdmin.
π³ Usage of web
- When you run:
docker compose logs -f web
or
docker-compose logs -f web
- It means:
- π "Show me the logs of the container(s) running under the service named web".
- Similarly, to get inside that container:
docker compose exec web bash
-
This attaches you to the PHP + Apache container defined under
web. -
β So, web is not random β it is the service name defined in your
docker-compose.ymlunder services
To access the PHP container shell:
docker exec -it <container_name> bash
To reset MySQL data:
docker volume rm <project_name>\_mysql_data