如何搭建支持WebDAV協(xié)議的服務(wù)器

前言:畢設(shè)是做一個基于WebDAV協(xié)議的云盤,所以需要搭建一個支持WebDAV協(xié)議的服務(wù)器來作為云盤來存儲文件。

關(guān)于WebDAV協(xié)議:百度 ,維基百科

系統(tǒng)要求:Ubuntu

搭建過程

# 安裝Apache2服務(wù)器
sudo apt-get  install  -y apache2

# 開啟Apache2中對WebDav協(xié)議的支持 (記住最好在用戶目錄下執(zhí)行否則報錯)
cd ~
sudo a2enmod dav
sudo a2enmod dav_fs

# 創(chuàng)建共享目錄并修改權(quán)限
sudo mkdir -p /var/www/webdav
sudo chown -R www-data:www-data  /var/www/webdav

#創(chuàng)建用戶`dev`
sudo htpasswd -c /etc/apache2/webdav.password dev

# 修改用戶數(shù)據(jù)庫訪問權(quán)限
sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password

# 打開默認(rèn)配置文件
sudo vim /etc/apache2/sites-available/000-default.conf

# 全部替換為以下內(nèi)容:
DocumentRoot /var/www/html

 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
 # error, crit, alert, emerg.
 # It is also possible to configure the loglevel for particular
 # modules, e.g.
 #LogLevel info ssl:warn

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 # For most configuration files from conf-available/, which are
 # enabled or disabled at a global level, it is possible to
 # include a line for only one particular virtual host. For example the
 # following line enables the CGI configuration for this host only
 # after it has been globally disabled with "a2disconf".
 #Include conf-available/serve-cgi-bin.conf

 DocumentRoot /var/www/webdav
 <Directory /home/ubuntu/webdav>
 Options Indexes MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 </Directory>

 Alias /webdav /var/www/webdav
 <Location /webdav>
 Options Indexes
 DAV On
 AuthType Basic
 AuthName "webdav"
 AuthUserFile /etc/apache2/webdav.password
 Require valid-user
 </Location>
</VirtualHost>



# 重啟Apache2服務(wù)器
sudo systemctl restart apache2
# 或
sudo /etc/init.d/apache2 reload</pre>

此時,在瀏覽器輸入:http://ip/webdav即可訪問

image.png

支持WebDav協(xié)議的客戶端工具有cadaver等,我使用的是Win版的Cyberduck,可以使用客戶端工具來驗證是否支持GET, PUT, DELETE, COPY等操作。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容