我在 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.html
或 index.php
要服务的 apache 文件。
关于Apache 禁止使用 Docker 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46000003/