Skip to content

Instantly share code, notes, and snippets.

@tr4nk
Last active January 21, 2018 03:14
Show Gist options
  • Save tr4nk/5e12b2e57af83d0c52124ed8b8bee102 to your computer and use it in GitHub Desktop.
Save tr4nk/5e12b2e57af83d0c52124ed8b8bee102 to your computer and use it in GitHub Desktop.
sample php-apache docker-compose file

Sample php-apache docker-compose file

Project directory structure

project

  • .docker
    • docker-compose.yml
    • vhost.conf

Notes

Set your database config host and port the same as environment variables DB_HOST and DB_PORT (defined in docker-compose.yml).

COMPOSE_PROJECT_NAME=project_name
version: '3'
services:
php-apache:
image: ktr4z/php:5.6-apache
volumes:
- ../:/code
- ./vhost.conf:/etc/apache2/sites-available/000-default.conf
ports:
- 80:80
environment:
- "DB_PORT=3306"
- "DB_HOST=db"
db:
image: db
environment:
- "MYSQL_DATABASE=mydb"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "3306:3306"
volumes:
- db:/var/lib/mysql
volumes:
db:
<VirtualHost *:80>
DocumentRoot /code/public
ServerName example.dev
<Directory "/code/public">
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment