【问题标题】:Apache 403 Forbidden You don't have permission to access / on this serverApache 403 Forbidden 您无权访问此服务器上的 /
【发布时间】:2019-02-16 08:13:31
【问题描述】:

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

“您无权访问此服务器上的 /”

。我在本地主机端口5002 使用Apache/2.4.25 (Debian) 服务器。该目录的路径是~/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       |
|---------------------|------------------|

~/tutorial/products

|---------------------|------------------|
|     -rwxr-xr-x      |     api.py       |
|---------------------|------------------|
|     -rwxr-xr-x      |    Dockerfile    |
|---------------------|------------------|
|     -rwxr-xr-x      |     index.php    |
|---------------------|------------------|
|     -rwxr-xr-x      | requirements.txt |
|---------------------|------------------|

【问题讨论】:

  • 用户组是什么?你在用 ubuntu 吗?仙人掌?如果你在 ubuntu 上,它应该是 www-data:www-data。如果不做 chown www-data:www-data -r /directory。 ~/tutorial/product 在 /signature 下吗?
  • 我正在使用 Ubuntu。我尝试了 chown 命令,但它显示invalid option --'r'。 ~/tutorial/product 在家里
  • 试试 sudo chown -R www-data:www-data ~/tutorial
  • 命令通过了,但仍然遇到权限问题。我真的需要一个名为signature 的目录吗?因为我没有
  • 看起来 apache 没有找到要服务的索引页面。确保您的卷映射正确(使用 docker exec 输入图像并检查 /var/www/html 文件夹的内容)。如果您的文件在那里,请确保您有一个 index.html 或 index.php 文件供 apache 使用。 - stackoverflow.com/questions/46000003/…

标签: apache docker


【解决方案1】:

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

在你的容器外发出这个命令。

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

【讨论】:

  • 这个答案很神奇。谢谢。
猜你喜欢
  • 1970-01-01
  • 2017-06-22
  • 2013-09-27
  • 2019-10-17
  • 2020-01-11
  • 2015-10-20
  • 1970-01-01
  • 2014-03-20
  • 2014-04-14
相关资源
最近更新 更多