Skip to content

Instantly share code, notes, and snippets.

@Soben
Last active February 28, 2023 03:08
Show Gist options
  • Save Soben/04cabded1d6f00f4e39cebef2748c426 to your computer and use it in GitHub Desktop.
Save Soben/04cabded1d6f00f4e39cebef2748c426 to your computer and use it in GitHub Desktop.
fly.io Barebones Apache Configuration for Slim PHP
FROM php:8.2-apache
# Install `zip` -- required for composer
RUN apt update \
&& apt install -y zip libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip
# Install Apache rewrite module
RUN a2enmod rewrite
# Point the Site to use port 8080, and for Apache to listen to this port instead of `:80` by default.
RUN sed -ri -e 's!:80>!:8080>!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!Listen 80!Listen 8080!g' /etc/apache2/ports.conf
# Copy over the files, and set the appropriate permissions
COPY --chown=www-data . /var/www/html
# Install composer and install production-only packages. no composer plugins
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install --no-dev --optimize-autoloader
# Point to the public folder to use as the site root.
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
WORKDIR /var/www/html
EXPOSE 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment