Apache-2.2

嘗試使用 docker 在本地安裝 Wordpress,其中一些文件夾符號連結到我的 git 目錄

  • September 19, 2022

將此圖像與 docker-compose.yml 一起使用:https ://hub.docker.com/_/wordpress 本書所做的一切,直到我嘗試將一些文件夾符號連結到我的 git 儲存庫為止。

這是我的一部分docker-compose.yml

wordpress:
   image: wordpress
   restart: always
   ports:
     - 80:80
   environment:
     WORDPRESS_DB_HOST: wordpressdb
     WORDPRESS_DB_USER: exampleuser
     WORDPRESS_DB_PASSWORD: examplepass
     WORDPRESS_DB_NAME: cms_local
   volumes:
     - ./wordpress:/var/www/html

文件夾中的一些外掛和主題wp-content/pluginswp-content/themes我刪除並創建了符號連結,而不是指向我的 git 儲存庫。不幸的是 Apache 無法訪問它們並拋出以下錯誤:

AH00037: Symbolic link not allowed or link target not accessible: /var/www/html/wp-content/themes/cms-child-theme, referer: http://localhost/

當我嘗試cd從 docker 進入這些文件夾時,出現以下錯誤:

lrwxr-xr-x  1 www-data www-data   80 Sep 19 12:25 cms-child-theme -> /Users/anatoly/Developer/example.com/wordpress/themes/cms-child-theme
-rw-rw-r--  1 root     root       28 Jun  5  2014 index.php
drwxr-xr-x 28 root     root      896 Jun 29  2021 twentyfifteen
drwxr-xr-x 42 root     root     1344 Jun 29  2021 twentyfourteen
drwxr-xr-x 34 root     root     1088 Jun 29  2021 twentynineteen
drwxr-xr-x 25 root     root      800 Jun 29  2021 twentysixteen
drwxr-xr-x 23 root     root      736 Jun 29  2021 twentytwenty
drwxr-xr-x 28 root     root      896 Jun 29  2021 twentytwentyone
drwxr-xr-x 12 root     root      384 Feb 28  2022 twentytwentytwo
root@47205851c7e7:/var/www/html/wp-content/themes# cd cms-child-theme
bash: cd: cms-child-theme: No such file or directory

能解決嗎?

符號連結在容器內解析。您可以將目錄添加為附加卷

volumes:
- ./wordpress:/var/www/html
- /Users/anatoly/Developer/example.com/:/Users/anatoly/Developer/example.com/

引用自:https://serverfault.com/questions/1111062