我是 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/