Webフォルダサーバー構築(WebDAV)(CentOS7)

提供:EELの自由帳

メインページ > CentOS 7 で自宅サーバー構築  > Webフォルダサーバー構築(WebDAV)(CentOS7)

共有ディレクトリ作成

  • ACL パッケージは OS の最小構成に含まれている。
  • ACLアクセス制御機能を利用して、WebDAVでアクセスするディレクトリのみ、apache権限での参照・更新を可能にする。
  • 既存のユーザーを使う場合は、ユーザ登録はしない。
[root@host3 ~]# useradd -s /sbin/nologin sudachi ← sudachiユーザ登録

[root@host3 ~]# passwd sudachi ← sudachiユーザパスワード設定
Changing password for user sudachi.
New UNIX password: ← パスワード応答
Retype new UNIX password: ← パスワード応答(確認)
passwd: all authentication tokens updated successfully.

[root@host3 ~]# chmod 711 /home/sudachi/ ← sudachiのホームディレクトリのパーミッションを変更

[root@host3 ~]# mkdir /home/sudachi/samba/ ← 共有ディレクトリ作成
[root@host3 ~]# chown sudachi. /home/sudachi/samba/ ← 共有ディレクトリの所有者をsudachiに変更

[root@centos ~]# setfacl -m g:apache:rwx,g:apache:rwx /home/sudachi/samba/
 ← 共有ディレクトリへapacheグループ権限で参照・更新・実行を許可

[root@host3 ~]# setfacl -m d:g:apache:rwx,g:apache:rwx /home/sudachi/samba/
 ← 共有ディレクトリへ新規作成するファイルへapacheグループ権限で参照・更新・実行を許可

[root@host3 ~]# setfacl -m g:sudachi:rwx,g:sudachi:rwx /home/sudachi/samba/
 ← 共有ディレクトリへsudachiグループ権限で参照・更新・実行を許可

[root@host3 ~]# setfacl -m d:g:sudachi:rwx,g:sudachi:rwx /home/sudachi/samba/
 ← 共有ディレクトリへ新規作成するファイルへsudachiグループ権限で参照・更新・実行を許可

[root@host3 ~]# ll /home/sudachi/ ← ACLアクセス設定確認
合計 8
drwxrwxr-x+ 2 sudachi sudachi    6  1月  2 11:08 webdav ← パーミッションの後ろに+が付いていること

[root@host3 ~]# getfacl /home/sudachi/samba/ ← 共有ディレクトリのACL設定確認
getfacl: Removing leading '/' from absolute path names
# file: home/sudachi/webdav/
# owner: sudachi
# group: sudachi
user::rwx
group::r-x
group:apache:rwx ← apacheグループによる参照・更新・実行が許可されている
group:sudachi:rwx ← sudachiグループによる参照・更新・実行が許可されている
mask::rwx
other::r-x
default:user::rwx
default:group::r-x
default:group:apache:rwx ← 新規作成するファイルにapacheグループによる参照・更新・実行が許可されている
default:group:sudachi:rwx ← 新規作成するファイルにsudachiグループによる参照・更新・実行が許可されている
default:mask::rwx
default:other::r-x
  • ACL設定をクリアする場合
    /home/sudachi/samba/ディレクトリのACL設定クリア
[root@host3 ~]# setfacl -b /home/sudachi/samba/

WebDAV設定

[root@host3 ~]# vi /etc/httpd/conf.d/webdav.conf
Alias /webdav /home/sudachi/samba
<Directory "/home/sudachi/samba">
    DAV On
    SSLRequireSSL
    AllowOverride None
    Options None
    AuthType Basic
    AuthName WebDAV
    AuthUserFile /etc/httpd/conf/.htpasswd
    Require user sudachi
</Directory>

[root@host3 ~]# systemctl restart httpd