Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattstabeler/eac5ee2f988693906b43c5ffa1d8c58e to your computer and use it in GitHub Desktop.
Save mattstabeler/eac5ee2f988693906b43c5ffa1d8c58e to your computer and use it in GitHub Desktop.
Apache PHP Docker Compose for Wordpress
<VirtualHost *:80>
ServerAdmin me@mydomain.com
DocumentRoot /var/www/site
<Directory /var/www/site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

docker-compose build www

docker-composer up -d wpdb redis www

version: '3.6'
services:
db:
image: mariadb
volumes:
- ./db-data:/var/lib/mysql
restart: always
ports:
- 3307:3306
environment:
MYSQL_ROOT_PASSWORD: mypassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
redis:
image: redis:alpine
ports:
- "6379:6379"
www:
volumes:
- ./:/var/www/site
# - apache-config.conf:/etc/apache2/sites-enabled/000-default.conf
build:
context: ./
dockerfile: Dockerfile
restart: always
environment:
DB_URL: mysql://wordpress:wordpress@wpdb:3306/wordpress
ports:
- 8080:80
FROM ubuntu:latest
MAINTAINER Matt Stabeler <matt@bigbadweb.co.uk>
# Install apache, PHP, and supplimentary programs. openssh-server, curl, and lynx-cur are for debugging the container.
RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \
apache2 php libapache2-mod-php curl php-mysql
RUN apt-get -y install php-mysql
RUN apt-get -y install php-opcache php-cli php-gd php-curl php-xml
# Enable apache mods.
RUN a2enmod php7.4
RUN a2enmod rewrite
# Update the PHP.ini file, enable <? ?> tags and quieten logging.
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.4/apache2/php.ini
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.4/apache2/php.ini
# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
# Expose apache.
EXPOSE 80
# Copy this repo into place.
# ADD www /var/www/site
# Update the default apache site with the config we created.
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# By default start up apache in the foreground, override with /bin/bash for interative.
CMD /usr/sbin/apache2ctl -D FOREGROUND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment