Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache在Docker中说:不允许符号链接_Apache_Symfony_Docker_Docker Compose - Fatal编程技术网

Apache在Docker中说:不允许符号链接

Apache在Docker中说:不允许符号链接,apache,symfony,docker,docker-compose,Apache,Symfony,Docker,Docker Compose,我使用Docker图像: 我将其与docker compose一起使用: apache: build: ./site/docker/apachephp environment: - VIRTUAL_HOST=www.test.dev volumes: - ./site/code:/var/www/app expose: - "80" 该代码是一个symfony应用程序,在web文件夹中使用符号链接,但对于apache日志中获得的符号链接中的所有资产: A

我使用Docker图像:

我将其与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-symlinksFownerMatch是否正确使用,是否有其他配置文件覆盖了某些内容

还是许可问题? 主机上的文件不属于apache用户www数据,而是属于另一个用户,但是设置了读取权限

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
#参见http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
互斥文件:/var/lock/apache2默认值
PidFile/var/run/apache2/apache2.pid
超时300
继续
MaxKeepAliveRequests 100
保持超时
用户www数据
组www数据
主机名查询
ErrorLog/proc/self/fd/2
日志级别警告
包括可选mods启用/*.加载
IncludeOptional mods enabled/*.conf
#ports.conf
听80
听我说
听我说
不允许超限
要求全部拒绝
选项+以下符号链接-符号链接所有者匹配
允许超越所有
要求所有授权
DocumentRoot/var/www/app/web
AccessFileName.htaccess
要求全部拒绝
日志格式“%v:%p%h%l%u%t\%r\“%>s%O\”%{Referer}i\“\”%{User-Agent}i\\”vhost\u
日志格式“%h%l%u%t\%r\”%>s%O\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\“%>s%O”通用
日志格式“%{Referer}i->%U”Referer
日志格式“%{User agent}i”代理
CustomLog/proc/self/fd/1组合
SetHandler应用程序/x-httpd-php
#同一上下文中的多个DirectoryIndex指令将添加
#要查找而不是替换的资源列表
# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
目录索引已禁用
目录索引app_dev.php index.php index.html
IncludeOptional conf enabled/*.conf
IncludeOptional sites enabled/*.conf
回答我自己的问题: 多亏了上面评论中的提示,我登录了容器并检查了路径和符号链接是主机的路径,因此无法工作


因此,我可能必须在容器中创建符号链接,除非有某种方法告诉docker从主机跟踪符号链接,但我对此表示怀疑。

我在符号链接方面也有问题,在我的情况下,这是因为链接具有来自系统根目录的物理路径,Docker以某种方式虚拟化了实例的路径。详情如下:

analyticsSync->/media/user/DATA/dev/web/ic/analytics/public/sync/analyticsSync

我通过创建相对符号链接解决了这个问题:

analyticsSync->ic/analytics/public/sync/analyticsSync

“/media/user/DATA”是我的数据分区的物理路径,Docker无法识别


我希望这会有所帮助。

您是否已输入正在运行的容器并检查了容器内使用的配置。有时,在哪里放置配置或如何正确引用配置会有点混乱。当我遇到这样的问题时,我的最佳实践是,运行容器,使用docker exec-I-t containername/bin/bash进入容器,看看里面发生了什么。我会使用
docker exec-ti
检查容器内的路径,看看那里有什么以及链接设置在哪里。您可以从
docker ps
获取容器名称。好主意,伙计们,我明天再试