【发布时间】:2016-01-27 02:05:02
【问题描述】:
我使用 Docker 镜像:https://github.com/docker-library/php/blob/fec7f537f049aafd2102202519c3ca9cb9576707/5.5/apache/Dockerfile
我将它与 docker-compose 一起使用:
apache:
build: ./site/docker/apachephp
environment:
- VIRTUAL_HOST=www.test.dev
volumes:
- ./site/code:/var/www/app
expose:
- "80"
代码是一个 symfony 应用程序并在 web 文件夹中使用符号链接,但对于符号链接中的所有资产,我在 apache 日志中获得:
AH00037:不允许符号链接或链接目标不可访问:/var/www/app/web/test
所有其他代码运行良好。
我想知道 Options +FollowSymLinks -SymLinksIfOwnerMatch 是否使用正确,是否有其他配置文件覆盖了某些东西?
或者是一些权限问题? 主机上的文件不属于 apache 用户 www-data 而是属于另一个用户,但是设置了读取权限。
Apache 配置是:
# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
Mutex file:/var/lock/apache2 default
PidFile /var/run/apache2/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User www-data
Group www-data
HostnameLookups Off
ErrorLog /proc/self/fd/2
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# ports.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
<Directory />
AllowOverride None
Require all denied
</Directory>
<Directory /var/www/app>
Options +FollowSymLinks -SymLinksIfOwnerMatch
AllowOverride All
Require all granted
</Directory>
DocumentRoot /var/www/app/web
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /proc/self/fd/1 combined
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# Multiple DirectoryIndex directives within the same context will add
# to the list of resources to look for rather than replace
# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
DirectoryIndex disabled
DirectoryIndex app_dev.php index.php index.html
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
【问题讨论】:
-
你是否进入了正在运行的容器并检查了容器内部使用的配置。有时在哪里放置配置或如何正确引用它有点令人困惑。当我遇到这样的问题时,我的最佳做法是,使用 docker exec -i -t containername /bin/bash 运行容器,然后看看里面发生了什么。
-
我会使用
docker exec -ti <container name>来检查容器内的路径,看看那里有什么以及链接的设置位置。您可以从docker ps获取容器名称。 -
好主意,明天试试
标签: apache symfony docker docker-compose