gpt4 book ai didi

apache - 为什么我收到错误 "You don' t have permission to access/on this server."?

转载 作者:行者123 更新时间:2023-12-04 19:12:19 24 4
gpt4 key购买 nike

我尝试在 docker 上运行我的网站,这是我的 docker-compose.yml:

version: '2'
services:
php:
image: yiisoftware/yii2-php:7.1-apache
volumes:
- ~/projects/my-project-name.local/composer-
docker/cache:/root/.composer/cache:delegated
- ./:/app:delegated
ports:
- '8000:80'

当我运行“docker-compose up -d --build”并打开一个 url localhost:8000 时,发生错误“Forbidden.You don't have permission to access/on this server.”
容器的日志是:
AH00112: Warning: DocumentRoot [/var/www/html] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.2. Set the 'ServerName' directive globally to suppress this message
AH00112: Warning: DocumentRoot [/var/www/html] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.2. Set the 'ServerName' directive globally to suppress this message
[Tue Jul 10 06:42:22.442648 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Tue Jul 10 06:42:22.442713 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Tue Jul 10 06:42:25.985025 2018] [core:error] [pid 17] [client 172.22.0.1:48650] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html
172.22.0.1 - - [10/Jul/2018:06:42:25 +0000] "GET / HTTP/1.1" 403 503 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
[Tue Jul 10 06:42:26.117774 2018] [core:error] [pid 17] [client 172.22.0.1:48650] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html, referer: http://localhost:8000/
172.22.0.1 - - [10/Jul/2018:06:42:26 +0000] "GET /favicon.ico HTTP/1.1" 403 513 "http://localhost:8000/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"

当我使用与 yii2 相同的 docker-compose.yml 时,一切正常。
请帮我解决这个问题。我的操作系统是 Ubuntu-18.04。

最佳答案

yii2 docker 镜像基于 php 镜像,在其 Dockerfile 中有以下几行:

# Copy the app code into the image
COPY . /var/www/html

这与日志中的警告一致。

当你把它添加到你的 Dockerfile 中时,你应该没问题(假设你的源代码在当前目录中)。

如果你想使用 docker 容器作为开发环境,你可以将源代码的文件夹挂载到 /var/www/html .在这种情况下,您必须添加一个卷:
volumes:
- .:/var/www/html # Add this line

关于apache - 为什么我收到错误 "You don' t have permission to access/on this server."?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51258971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com