nginx、php-fpm、dockerではシンボリックリンクは機能しません。

nginx、php-fpm、dockerではシンボリックリンクは機能しません。

dockerを使用してローカルでWordPressサイトを実行しており、プラグインはシンボリックリンクであるstyle.cssファイルにGET要求を送信しますが、動作せずに応答します。404 not found

GET URIは正確で、シンボリックリンクの代わりにハードリンクパスを使用すると機能するため、WordPressに問題があるとは思わない。

したがって、問題はnginx、docker、またはnginxのphp-fpm設定である可能性があります。

これまで、stackexchangeサイトでいくつかのアイデアを見つけましたが、成功しませんでした。

  • disable_symlinks off;http、サーバー、場所(場所/~ \.php$場所)の3つのコンテキストでnginx設定に明示的に追加します。
  • autoindex on;nginx、サーバー、およびすべての場所コンテキストを追加する
  • $document_rootnginxを$realpath_root次のように変更します。
    • fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  • 次の2行を追加してください。
    • fastcgi_param DOCUMENT_ROOT $realpath_root;
    • fastcgi_param PATH_TRANSLATED $realpath_root$fastcgi_script_name;
  • ハードリンクとシンボリックリンクの場所にあるファイルとフォルダに対する読み取りと実行の許可
  • ファイルとフォルダの所有者を有効なハードリンクと同じ所有者に変更します(私のnginxとwordpress dockerは2つのコンテナにあります)

また何をすべきかわかりませんか?

必要:

WordPress GET要求に失敗しました(コード、要求、およびヘッダー):

  • wp_enqueue_style('my_style', plugins_url('style.css', __FILE__));
  • https://localhost/wp-content/plugins/my_plugin/style.css
  • タイトル:
GET https://localhost/wp-content/plugins/my_plugin/style.css?ver=6.0.3
Status 404 Not Found
Version HTTP/1.1
Transferred 294 B (146 B size)
Referrer Policy strict-origin-when-cross-origin

有効なWordPress GETリクエスト(ハードリンク)(コード、リクエスト、ヘッダ):

  • wp_enqueue_style('my_style', plugins_url( 'test_plugin/style.css', dirname(__FILE__) ));
  • https://localhost/wp-content/plugins/test_plugin/style.css
  • タイトル:
GET https://localhost/wp-content/plugins/test_plugin/style.css?ver=6.0.3
Status 200 OK
Version HTTP/1.1
Transferred 548 B (318 B size)
Referrer Policy strict-origin-when-cross-origin

建築学:

                                 /
drwxr-xr-x  www-data:www-data    | home/
drwxr-xr-x  www-data:www-data    | | www-data
drwxr-xr-x  www-data:www-data    | | | my_plugin/
-rwxr-xr-x  www-data:www-data    | | | | index.php
-rwxr-xr-x  www-data:www-data    | | | | style.css
drwxr-xr-x  root:root            | var/
drwxr-xr-x  root:root            | | www/
drwxr-xr-x  www-data:www-data    | | | html/
drwxr-xr-x  www-data:www-data    | | | | wp-content/
drwxr-xr-x  www-data:www-data    | | | | | plugins/
lrwxrwxrwx  www-data:www-data    | | | | | | my_plugin/ -> /home/www-data/my_plugin
drwxr-xr-x  www-data:www-data    | | | | | | test_plugin/
-rwxr-xr-x  www-data:www-data    | | | | | | | style.css

ベストアンサー1

私は解決策を見つけ、それは私の立場で非常に愚かな間違いでした。

ハードリンクを含むボリュームをNginx-Containerに提供するのを忘れました!したがって、Nginxコンテナにはシンボリックリンクが指すハードリンクはありません。

おすすめ記事