apache - Apache Docker 容器中使用了错误的 DocumentRoot
问题描述
即使我DocumentRoot
在配置中指定了 a,我也需要指定包含在其中的子文件夹DocumentRoot
以加载 URL。
- 作品:192.168.2.35/default/index.html
- 不起作用,但需要:192.168.2.35/index.html
docker exec -it apache httpd -S
显示加载的虚拟主机的输出:
me@server:/var/www/html$ docker exec -it apache httpd -S
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
192.168.2.35:80 localhost (/usr/local/apache2/conf/enabled-sites/default.conf:10)
ServerRoot: "/usr/local/apache2"
Main DocumentRoot: "/usr/local/apache2/htdocs"
Main ErrorLog: "/proc/self/fd/2"
Mutex default: dir="/usr/local/apache2/logs/" mechanism=default
PidFile: "/usr/local/apache2/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
我的 Docker 容器卷:
"Binds": [
"/var/www/html:/usr/local/apache2/htdocs:rw",
"/etc/apache2/conf:/usr/local/apache2/conf:ro",
"/var/log/apache2:/usr/local/apache2/logs:rw"
],
default.conf
:
<Directory /usr/local/apache2/htdocs/default>
Options -Indexes
AllowOverride All
Require all granted
</Directory>
<VirtualHost 192.168.2.35:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /usr/local/apache2/htdocs/default
LogLevel debug
ErrorLog logs/error.default.ca.log
CustomLog logs/access.default.ca.log combined
</VirtualHost>
解决方案
为虚拟主机指定的 IP 与 Docker 使用的 IP 不匹配。
在虚拟主机中使用*:80
可以修复它。
推荐阅读
- c# - 退出游戏后掷骰子游戏循环不止一次
- snakemake - 如何在snakemake中正确使用批处理标志来子集DAG
- azure - Azure 存储的数据保留
- python - 尝试使用 matplotlib,但出现错误
- swift - 访问函数 Swift 之外的变量
- sql - 在定期刷新实时 SQL Server 表的新服务器上设置新数据库的最佳方法是什么?
- java - 无论如何在Idea中识别由lombok在同一模块中生成的getter/setter
- xamarin - Xamarin.Android 中的 JavascriptInterface 已过时,无法从 Javascript 调用 C#
- c# - 为什么更改 Exchange 传输代理中的发件人/发件人会导致该用户的主地址?
- html - 如何在本地存储中进行角度更新用户名的当前用户值