πŸš€ 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.ini and apache configs included
  • 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
  • phpMyAdmin

  • 🐳 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.

πŸ“‚ 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 compose command:
  • For older versions of Docker Compose, use the docker-compose command:

1.1 To build containers:

  • Before running docker compose build, make sure the required SQL seed file is placed in docker/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.yml under services

To access the PHP container shell:

docker exec -it <container_name> bash

To reset MySQL data:

docker volume rm <project_name>\_mysql_data

Use / to focus search. Press Enter to run. Esc clears.