Apache 禁止使用 Docker 访问

标签 apache docker server

我在 docker-compose.yml 上构建了这个图像

version: '2'

services:
  webserver:
  build: ./docker/webserver
  image: image_name
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - /Users/user_name/Sites/site:/var/www/html

并在 Dockerfile 上执行此命令
 FROM php:7-apache
 RUN apt-get update -y && apt-get install -y libpng-dev && apt-get 
 install -y libcurl4-openssl-dev
 RUN docker-php-ext-install pdo pdo_mysql gd curl
 RUN a2enmod rewrite
 RUN service apache2 restart

但我明白了
Forbidden

You don't have permission to access / on this server.
Apache/2.4.10 (Debian) Server at localhost Port 80

当我去本地主机时。

我用 Mac 工作。
我已经将 docker 文件用于其他项目,并且一切正常。
我错过了什么?

记录响应

Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

最佳答案

看起来 apache 没有找到要提供的索引页面。确保您的卷映射正确(输入带有 docker exec 的图像并检查 /var/www/html 文件夹的内容)。如果您的文件在那里,请确保您有 index.htmlindex.php要服务的 apache 文件。

关于Apache 禁止使用 Docker 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46000003/

相关文章:

C++ uWebSockets 在一个线程中集成事件循环

javascript - 单击按钮时如何让用户下载多个文件?

ssl - 将 artifactory 设置为 docker registry 时出现问题

php - docker debian 拉伸(stretch)镜像中缺少 php-redis 存储库

arrays - 如何将字符串拆分为数组并循环遍历它?

c - 单 socket 多线程接收器

mysql - 安装 xampp 后运行 apache 时出错

linux - Video.js 源不在 Apache 文件夹中

mysql - 如何在一个命令中将 Linux VPS 重置为 0?

laravel-5 - Laravel 5.1 服务器无法启动