Debian 11.2にWebDAVを利用してファイルサーバーを設定する方法

環境
OSバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/debian_version
11.2
# cat /etc/debian_version 11.2
# cat /etc/debian_version
11.2

apache2バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# apache2 -v
Server version: Apache/2.4.53 (Debian)
Server built: 2022-03-14T16:28:35
# apache2 -v Server version: Apache/2.4.53 (Debian) Server built: 2022-03-14T16:28:35
# apache2 -v
Server version: Apache/2.4.53 (Debian)
Server built: 2022-03-14T16:28:35

操作方法

1.apache2-utilsをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# apt -y install apache2-utils
# apt -y install apache2-utils
# apt -y install apache2-utils

2.ユーザー認証が必要な [webdav]ディレクトリを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# mkdir /home/webdav
# chown www-data. /home/webdav
# chmod 770 /home/webdav
# mkdir /home/webdav # chown www-data. /home/webdav # chmod 770 /home/webdav
# mkdir /home/webdav
# chown www-data. /home/webdav
# chmod 770 /home/webdav

3.SSL通信を設定します
# nano /etc/apache2/sites-available/webdav.conf
以下の内容を追記します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Alias /webdav /home/webdav
<Location /webdav>
DAV On
SSLRequireSSL
Options None
AuthType Basic
AuthName WebDAV
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Location>
Alias /webdav /home/webdav <Location /webdav> DAV On SSLRequireSSL Options None AuthType Basic AuthName WebDAV AuthUserFile /etc/apache2/.htpasswd Require valid-user </Location>
Alias /webdav /home/webdav
<Location /webdav>
    DAV On
    SSLRequireSSL
    Options None
    AuthType Basic
    AuthName WebDAV
    AuthUserFile /etc/apache2/.htpasswd
    Require valid-user
</Location>

4.モジュールdavを有効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# a2enmod dav*
Enabling module dav.
Considering dependency dav for dav_fs:
Module dav already enabled
Enabling module dav_fs.
Enabling module dav_lock.
To activate the new configuration, you need to run:
systemctl restart apache2
# a2enmod dav* Enabling module dav. Considering dependency dav for dav_fs: Module dav already enabled Enabling module dav_fs. Enabling module dav_lock. To activate the new configuration, you need to run: systemctl restart apache2
# a2enmod dav*
Enabling module dav.
Considering dependency dav for dav_fs:
Module dav already enabled
Enabling module dav_fs.
Enabling module dav_lock.
To activate the new configuration, you need to run:
  systemctl restart apache2

5.webdav配置ファイルを反映します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# a2ensite webdav
Enabling site webdav.
To activate the new configuration, you need to run:
systemctl reload apache2
# a2ensite webdav Enabling site webdav. To activate the new configuration, you need to run: systemctl reload apache2
# a2ensite webdav
Enabling site webdav.
To activate the new configuration, you need to run:
  systemctl reload apache2

6.apache2を再起動します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl restart apache2
# systemctl restart apache2
# systemctl restart apache2

7.ユーザーを登録します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# htpasswd -c /etc/apache2/.htpasswd debian
New password:                   # パスワード入力
Re-type new password:            # パスワード確認
Adding password for user debian
# htpasswd -c /etc/apache2/.htpasswd debian New password:                   # パスワード入力 Re-type new password:            # パスワード確認 Adding password for user debian
# htpasswd -c /etc/apache2/.htpasswd debian
New password:                   # パスワード入力
Re-type new password:                 # パスワード確認
Adding password for user debian

 

Debian 11

Posted by arkgame