Provide an dev environnement for Apache and php with a specific version.
- Docker v28+ & Docker compose v2.4+
Makecommand. On linux, install withsudo apt install build-essential. On Windows, see here.- These ports must be available for docker:
8000, 9003(you can change it on.docker/apachephp/app.ymlor create adocker-compose.override.ymlfile after install).
Put your project files on demo folder (you can rename if you edit docker/*/.yml files), or you can your folder as a git repository instead. You can edit .env files on COMPOSE_FILE variable for add additionals docker compose config files (splitted by a comma ,).
Exemple:
COMPOSE_FILE=.docker/apachephp/app.yml,.docker/database/mysql.yml,.docker/database/phpmyadmin.yml
# [Optional] You can set php version, recommanded: 7.4, 8.4+
PHP_VERSION=8.4
# [Optional] php5 support, recommanded: 5.6
PHP_VERSION=5.6
XDEBUG_CONFIG_FILE=98-xdebug-php5.ini
# [Optional] Anothers docker settings, look at .env for complete list
APP_PORT=8000
RESTART_POLICY=on-failureOnce prepare, use command lines:
make installThe Makefile can be completed: if you use a Symfony Project --> uncomment some lines.
Use docker for execute the built-in web server and access the application in your browser at http://localhost:8000:
make up
# For stop services
make stop
# Help: List command
makeEnjoy http://localhost:8000 !
You can use your local database for this docker service:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Edit values:
# bind-address = 0.0.0.0
# collation-server = utf8mb4_unicode_ci
# character-set-server = utf8mb4
#
# For php5 version:
# default-authentication-plugin = mysql_native_passwordA configured mysql user is required (or psgql equivalent):
# PHP5
CREATE USER IF NOT EXISTS 'dockeruser'@'%' IDENTIFIED WITH mysql_native_password BY 'passdocker';
# Recent php
CREATE USER IF NOT EXISTS 'dockeruser'@'%' IDENTIFIED BY 'passdocker';
GRANT ALL PRIVILEGES ON dbname.* TO 'dockeruser'@'%';
FLUSH PRIVILEGES;Uncomment and edit settings DB_* in .env, keep DB_HOST with the configured value.
This project can use the local Apache server as a lightweight reverse proxy to route custom .localhost domains (e.g. project.localhost) to Docker containers.
This allows clean, port-free URLs in the browser without relying on Traefik or modifying the system hosts file.
The setup is intended for local development only and keeps Docker networking simple while preserving a realistic domain-based workflow.
project=demo
sudo cp $(pwd)/.docker/apachephp/apache_proxy.conf /etc/apache2/sites-available/${project}.conf
# edit /etc/apache2/sites-available/[project].conf
# ServerName: [ProjectNAME].localhost
# ProxyPass/ProxyPassReverse: PORT used in apache docker
sudo a2ensite ${project}.conf && sudo a2enmod proxy proxy_http && sudo service apache2 restartEnjoy http://demo.localhost !