🚀 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
├── 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. To build containers:
docker compose build
or
docker-compose build
1. After successful build, run:
docker compose up -d
or
docker-compose up -d
2. Access Services
App → http://localhost
phpMyAdmin → http://localhost:8081
3. 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