Apache 403 Forbidden 您无权访问/在此服务器上

标签 apache docker

我是 Docker 和 Apache 的新手,正在尝试执行一个非常简单的程序,该程序将在我的本地主机上显示一个网页。但是,我不断收到 403 Forbidden error

"You don't have permission to access / on this server"



.我正在使用 Apache/2.4.25 (Debian)服务器在 localhost 端口 5002 .目录的路径是 ~/tutorial/product .我在这里阅读了许多解决方案,并尝试了所有解决方案,但没有一个对我有用。

/etc/apache2/apache2.conf
<Directory /var/www/html>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

/etc/apache2/sites-enabled/000-default.conf
ServerAdmin webmaster@localhost
DocumentRoot /var/www/signature

<Directory /var/www/signature/>
   Allowoverride all
   Order allow,deny
   Allow from all
   Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

我已经使用 ls -l 在路径中的每个目录中包含了权限:

~/教程
|---------------------|------------------|
|     -rwxr-xr-x      |docker-compose.yml|
|---------------------|------------------|
|     drwxr-xr-x      |    product       |
|---------------------|------------------|
|     drwxr-xr-x      |    website       |
|---------------------|------------------|

~/教程/产品
|---------------------|------------------|
|     -rwxr-xr-x      |     api.py       |
|---------------------|------------------|
|     -rwxr-xr-x      |    Dockerfile    |
|---------------------|------------------|
|     -rwxr-xr-x      |     index.php    |
|---------------------|------------------|
|     -rwxr-xr-x      | requirements.txt |
|---------------------|------------------|

最佳答案

您的 Docker 容器中缺少文件。您需要发出以下命令将您的文件从您的机器带到 docker 容器。

在您的容器外发出此命令。

docker cp index.php 4fdb84ef3ef4:/var/www/html/index.php

关于Apache 403 Forbidden 您无权访问/在此服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282432/

相关文章:

php - Piwik 安装不工作

java - 使用intellij将Spring项目部署到apache tomcat8

apache - Docker www-data 授予对 var/www 的写入权限

docker - gcloud ai平台Hypertune将环境变量传递给自定义容器

docker - 如何从 Dockerfile 上的父镜像中删除入口点

docker - 如果一群人完全停止了,docker服务配置或 secret 会怎样?

docker - 无法将现有数据挂载到 kubernetes 中的持久卷

java - 错误: "org.apache.axis2.AxisFault: Transport error: 403 Error: Forbidden"

java - 我怎么知道 tomcat 是否在 Apache 后面运行?

docker - kubernetes pods 无法与外界通信