Skip to content

Instantly share code, notes, and snippets.

@romaricdrigon
Last active January 10, 2019 09:56
Show Gist options
  • Select an option

  • Save romaricdrigon/3edc87d641ad12612363ecb9621870c2 to your computer and use it in GitHub Desktop.

Select an option

Save romaricdrigon/3edc87d641ad12612363ecb9621870c2 to your computer and use it in GitHub Desktop.
LAMP setup for Symfony
version: '2'
volumes:
mysqldata: ~
services:
php:
build: .
depends_on:
- mysql
volumes:
- .:/var/www/html
working_dir: /var/www/html
ports:
# On se lit au port 80 local, mais on pourrait aussi en choisir un autre comme par exemple "8080:80"
- "80:80"
mysql:
image: mysql:5.7
volumes:
- mysqldata:/var/lib/mysql
environment:
# Nécessaire
- MYSQL_ROOT_PASSWORD=rootpass0
# On peut configurer sa BDD et les credentials pour s'y connecter
- MYSQL_DATABASE=mydb
- MYSQL_USER=dbuser
- MYSQL_PASSWORD=dbpass
ports:
# On rend la BDD accessible depuis notre ordinateur pour le débug
- "3306:3306"
FROM php:7.2-apache
# Dépendences nécessaires pour les extensions PHP, plus Wget/Git/SSH
RUN apt-get update && apt-get install --no-install-recommends -yq ${BUILD_PACKAGES} \
build-essential \
wget \
ssh \
git \
libmcrypt-dev \
libicu-dev \
libzip-dev \
&& apt-get clean
# Quelques extensions PHP recommmandées
ENV PHP_EXTENSIONS opcache pdo_mysql pcntl intl zip
RUN docker-php-ext-install ${PHP_EXTENSIONS}
# Installation de composer
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin
# Activation d'Apache mod_rewrite
RUN a2enmod rewrite
# On configure un vhost, pour ne pas avoir de public/ ou web/ dans l'URL
COPY vhost.conf /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# Pour Symfony 4
DocumentRoot /var/www/html/public
# Pour Symfony 2 ou 3
# DocumentRoot /var/www/html/web
# Également à changer pour Symfony 2/3, pour /web
<Directory "/var/www/html/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