Apacheでsshfs先のファイルを表示する

先日ご紹介した(ssh 経由で LAN 上のボリュームをマウントできる)sshfs ですが、Apache の DocumentRoot 配下に設置するとうまく表示できなかったのでメモ。

sshfsは便利 – あららぼ

ちなみに、ブラウザから見ると、ステータスコード 403 で返ってくる。

Forbidden
You don't have permission to access this resource.

ログを見てみると、権限がないと言われている。

[Sun Oct 05 17:26:05.508622 2025] [core:error] [pid 1679:tid 1679] (13)Permission denied: [client 192.168.xxx.xxx:50620] AH00035: access to /sshfs-xxx/ denied (filesystem path '/var/www/html/sshfs-xxx') because search permissions are missing on a component of the path

sshfs の help に書いてあった。

    -o allow_other         allow access by all users

ということで、オプション指定をすれば Apache で正常に表示できた。

sshfs -o allow_other {username}@192.168.xxx.xxx:/media/xxx /var/www/html/sshfs-xxx

実際には、Linux ファイルシステムのパーミッションと合わせて設定することになると思うので、使用は自己責任で。