前言:畢設(shè)是做一個(gè)基于WebDAV協(xié)議的云盤(pán)躲履,所以需要搭建一個(gè)支持WebDAV協(xié)議的服務(wù)器來(lái)作為云盤(pán)來(lái)存儲(chǔ)文件见间。
關(guān)于WebDAV協(xié)議:百度 ,維基百科
系統(tǒng)要求:Ubuntu
搭建過(guò)程
# 安裝Apache2服務(wù)器
sudo apt-get install -y apache2
# 開(kāi)啟Apache2中對(duì)WebDav協(xié)議的支持 (記住最好在用戶(hù)目錄下執(zhí)行否則報(bào)錯(cuò))
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)建用戶(hù)`dev`
sudo htpasswd -c /etc/apache2/webdav.password dev
# 修改用戶(hù)數(shù)據(jù)庫(kù)訪(fǎng)問(wèn)權(quán)限
sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password
# 打開(kāi)默認(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>
此時(shí)工猜,在瀏覽器輸入:http://ip/webdav
即可訪(fǎng)問(wèn)
支持WebDav協(xié)議的客戶(hù)端工具有cadaver等米诉,我使用的是Win版的Cyberduck,可以使用客戶(hù)端工具來(lái)驗(yàn)證是否支持GET, PUT, DELETE, COPY等操作篷帅。