【发布时间】:2014-09-09 18:15:40
【问题描述】:
在 docker 容器中安装 apache 网络服务器后,我想显示一个示例页面以确保其正常工作。但是我总是得到 404 Not found。
这是 dockerfile
FROM ubuntu:14.04
MAINTAINER <mail@example.org>
RUN DEBIAN_FRONTEND=noninteractive
# Install required packages
RUN apt-get -y update
RUN apt-get install -y apache2 libapache2-mod-php5 php5-gd php5-json php5-mysql php5-curl php5-intl php5-imagick bzip2 wget
# Enable the php mod
RUN a2enmod php5
# Configuration for Apache
ADD ./apache.conf /etc/apache2/sites-available/
RUN ln -s /etc/apache2/sites-available/apache.conf /etc/apache2/sites-enabled/
RUN a2enmod rewrite
RUN mkdir /var/www/test && echo "<html><body><h1>Yo</h1></body></html>" >> /var/www/test/index.html
EXPOSE :80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
apache.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory /var/www/test/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
容器已启动并正在运行。将 80 端口转发到主机上的 8080。
当我浏览到 localhost:8080 时,我可以看到 apache2 默认页面。但是,当我转到 localhost:8080/test/index.html 时,我只得到 404 Not found。
【问题讨论】:
-
我在你的 .conf 文件中没有看到:ServerName "your.domain" 或 localhost
标签: php apache apache2 webserver docker