Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Production ready Dockerfile for PHP and Apache
FROM php:7.4-apache
# update & upgrade
RUN apt-get update -y && apt-get upgrade -y && apt-get install apt-utils -y
# Php extensions
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions intl bcmath gd pdo_mysql opcache uuid exif pcntl zip
COPY php.ini /usr/local/etc/php/conf.d/app.ini
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Apache
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite && \
sed -i \
-e 's~^ServerSignature On$~ServerSignature Off~g' \
-e 's~^ServerTokens OS$~ServerTokens Prod~g' \
COPY index.php .
CMD ["apachectl", "-D", "FOREGROUND"]
date.timezone = Europe/Paris
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 128
opcache.revalidate_freq = 0
apc.enable_cli = On
upload_max_filesize = 16M
post_max_size = 16M
realpath_cache_size = 4096k
realpath_cache_ttl = 7200
display_errors = Off
display_startup_errors = Off
expose_php = Off
<VirtualHost *:80>
DocumentRoot /app
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /app/>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment