Configuration apache2 et php-fpm en mode conteneur.
Bonjour à tous
Je poste ici un soucis lié à docker car j'ai l'impression que cela vient plus d'un soucis apache2 et virtualhost que de docker.
Voila, j'ai 2 conteneurs, un avec php-fpm.
Si dessous le dockerfile:
Code:
1 2 3 4
| FROM php:5.5-fpm
WORKDIR /var/www
EXPOSE 9000
CMD ["php-fpm"] |
Je lance un build et un run
Code:
1 2
| docker build -t phpfpm .
docker run -ti --name PHP -p 9000:9000 -v /var/www:/var/www -d phpfpm |
Ensuite j'ai créé mon propre dockerfile pour apache2:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| FROM ubuntu
MAINTAINER PascalCanadas "leknoppix@users.noreply.github.com"
ENV DEBIAN_FRONTEND noninteractive
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
# Depots, mises a jour et installs
RUN apt-get update && \
apt-get upgrade -y -q && \
apt-get dist-upgrade -y -q \
&& apt-get -y -q autoclean && \
apt-get -y -q autoremove && \
apt-get install -y -q \
apache2 \
vim
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
RUN apt-get install -y -q apache2-mpm-worker apache2-mpm-event
RUN apt-get install -y -q libapache2-mod-fcgid
RUN a2dismod mpm_prefork
RUN a2enmod rewrite && \
a2enmod proxy && \
a2enmod proxy_fcgi
RUN a2enmod actions alias
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] |
Et je le lance avec:
Code:
1 2
| docker build -t apache2.
docker run --link PHP --name WEB -p 80:80 -v /var/www:/var/www -v /var/docker/apache2/site:/etc/apache2/site-enabled -ti apache2 |
Le serveur apache2 fonctionne. Par contre, pour le relier, j'utilise un proxy fcgi pour que les fichiers php soit interprété.
Voici mon virtualhost actuel:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DirectoryIndex index.html index.php
DocumentRoot /var/www
<Directory "/var/www">
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://PHP:9000/var/www/$1
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
Hors, quand je charge un projet php ou un simple fichier contenant un phpinfo(); cela fonctionne.
Par contre, la racine de mon serveur, j'ai un file File not found. quand je teste l'ouverture d'un simple fichier html, il se charge.
Quelqu'un aurait-il une idée de la source de mon soucis?
Merci d'avance.
lemirandais