Apache禁止使用Docker访问 [英] Apache forbidden access with Docker
问题描述
我在docker-compose.yml上构建此映像
I build this image on 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上使用此命令
And have this commands on 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文件用于其他项目,并且都运行良好. 我想念什么?
I work with Mac. I have used the docker files to other project and all worked great. what am I missing?
日志响应
无法提供目录/var/www/html/:没有匹配的DirectoryIndex (index.php,index.html)以及服务器生成的目录索引 选项指令禁止
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
文件.
Looks like apache is not finding an index page to serve. Ensure your volume mapping is correct (enter the image with docker exec
and check contents of /var/www/html
folder). If your files are there, ensure that you have an index.html
or index.php
file for apache to be served.
这篇关于Apache禁止使用Docker访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!