我正在尝试一个使用apache来处理请求的PHP Web应用程序。但是,当我尝试连接到虚拟主机时,它只是导致端口80进入connection time out
。我已经暴露了Dockerfile
中的端口80。
这里是docker-compose.yml
---
version: '2'
services:
apache:
image: apache-php-7.0
container_name: test
ports:
- "80:80"
- "443:443"
volumes:
- C:/asdn/Mounts:/srv/www/vhosts/lol/lol1/mounts
- C:/asdn/NonBackupMounts:/srv/www/vhosts/lol/nbmounts
- C:/asdn/Interfaces:/srv/www/vhosts/lol/interfaces
- C:/asdn/Logs:/srv/www/vhosts/lol/logs
- C:/asdn/PsCore/trunk:/srv/www/vhosts/lol/lol1
- C:/asdn/PsCoreCommon/trunk:/srv/www/vhosts/lol/Common/
- C:/asdn/PsLibraries/trunk:/srv/www/vhosts/lol/libraries
- C:/asdn/PsCoreConfig/trunk:/srv/www/vhosts/lol/coreconfig
hostname: xyz.com
networks:
- e-network
networks:
e-network:
driver: bridge
这是vhost
文件:
<VirtualHost *:80>
ServerName system.xyz.com
DocumentRoot /srv/www/vhosts/lol/lol1/www/System/
ErrorLog /var/log/apache2/system_error.log
CustomLog /var/log/apache2/system_custom.log common
Alias /Common /srv/www/vhosts/lol/Common
<Directory "/srv/www/vhosts/lol/lol1/www/System/">
<LimitExcept GET POST HEAD>
Require all granted
</LimitExcept>
AllowOverride None
Options all
Require all granted
</Directory>
<Directory "/srv/www/vhosts/lol/Common/">
<LimitExcept GET POST HEAD OPTIONS>
Require all denied
</LimitExcept>
AllowOverride None
Options None
Require all granted
</Directory>
</VirtualHost>
这是我用来构建映像的Dockerfile:
FROM php:7.0.30-apache
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
libc-client-dev \
libedit-dev \
libkrb5-dev \
libmcrypt-dev \
libreadline-dev \
librecode-dev \
libpq-dev \
libssl-dev \
libxml2-dev \
libz-dev \
zlib1g-dev \
libldb-dev \
libldap2-dev \
git \
vim
# Create so linkers for ldap
RUN ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so
RUN apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg-dev \
&& docker-php-ext-configure gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr/lib \
--with-freetype-dir=/usr/include/freetype2 \
&& docker-php-ext-install gd
RUN docker-php-ext-configure imap \
--with-imap-ssl \
--with-kerberos \
&& docker-php-ext-install imap
RUN docker-php-ext-install \
bcmath \
mbstring \
mcrypt \
mysqli \
opcache \
recode \
readline \
soap \
xml \
xmlrpc \
pgsql \
ldap \
pdo_pgsql \
soap \
sockets \
zip
# Installation of Composer
RUN cd /usr/src && curl -sS http://getcomposer.org/installer | php
RUN cd /usr/src && mv composer.phar /usr/bin/composer
RUN pecl install redis
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN apt-get update && apt-get install -y libmagickwand-6.q16-dev --no-install-recommends \
&& ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin \
&& pecl install imagick
RUN apt install -y libsodium-dev
RUN pecl install libsodium
RUN docker-php-ext-enable \
imagick \
mcrypt \
opcache \
redis \
xdebug \
sodium
RUN usermod -u 1000 www-data
WORKDIR /srv/www/vhosts
RUN chown -R www-data:www-data /srv/www/* /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libmcrypt-dev
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
# Enable rewrite and headers
RUN a2enmod rewrite && a2enmod headers
# Copy system portal vhost
COPY vhost/ /etc/apache2/sites-available/
RUN find /etc/apache2/sites-available/*.conf -type f -and -not -name "*default*" -exec a2ensite {} \;
# Enable site
#RUN a2ensite vhost.conf
# Restart apache
RUN service apache2 restart
EXPOSE 80 9000