我正在嘗試爲現有站點設置定製的碼頭集裝箱。要做到這一點,我想提供我自己的自定義vhost
配置與ServerName
。Apache無法確定碼頭集裝箱上的服務器名稱
但是當我嘗試添加自定義vhost configuration
和重啓apache我得到阿帕奇無法確定全局名稱警告:Could not reliably determine the server's fully qualified domain name, using 172.26.0.2. Set the 'ServerName' directive globally to suppress this message
什麼是重要的是,當我登錄到容器的外殼和手動運行service apache2 restart
我不再收到此警告。
我該如何抑制構建?我應該以其他方式將vhost
提供給作曲家嗎?
這是我docker-compose.yml
是這樣的:
version: '3'
services:
web:
build:
context: ./etc/php
args:
- APP_HOST=${APP_HOST}
ports:
- ${APP_PORT}:80
- ${APP_PORT_SSL}:443
volumes:
- ./var/bin/:/tmp/bin/
- ./app/:/var/www/html/
- ./log/:/var/log/
- ./etc/php/conf/:/usr/local/etc/php/conf.d/
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
然後,Dockerfile
,增加了我自己可用的站點:
FROM php:7.0-apache
ENV TERM=xterm
LABEL maintainer="Derek P Sifford <[email protected]>" \
version="0.15.2-php7.0"
ARG APP_HOST
ENV APP_HOST=$APP_HOST
ADD ./sites/app.conf /etc/apache2/sites-available/app.conf
RUN sed -i 's/ServerName APP_HOST/ServerName '$APP_HOST'/g' /etc/apache2/sites-available/app.conf
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf \
&& a2enmod rewrite expires \
&& a2dissite 000-default.conf \
&& a2ensite app.conf \
&& service apache2 restart
WORKDIR /app
EXPOSE 80 443
很顯然站點配置:
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName APP_HOST
SetEnv APPLICATION_ENV "development"
<Directory "/var/www/html">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
通過添加'echo「ServerName localhost解決方案| tee /etc/apache2/conf-available/fqdn.conf && \ a2enconf fqdn'到Dockerfile。謝謝:) – Moby04