K162

Starwalker, Stardust.

0%

Configure WebDAV with Apache2

Recently, I try to manage the documents, papers and references with Zotero. To keep my libraries updated between my devices and multi platforms, I decide to set up my Raspberry Pi (using Raspberry Pi OS) as an WebDAV server.

If you are in a Linux environment such as Ubuntu, the steps for configuration are similar.

Step 1: Install Apache2 and enable WebDAV module

Firstly, we need to install Apache Web server to enable WebDAV file sharing:

1
sudo apt install apache2

And enable WebDAV module with the directive following:

1
2
sudo a2enmod dav
sudo a2enmod dav_fs

Step 2: Create the directory for WebDAV

We will organize the documents files within the folder we created:

1
sudo mkdir /var/www/webdav

Remember to set the owner and group of the directory to apache’s user and group, granting permission to www-data:

1
sudo chown www-data:www-data /var/www/webdav

Step 3: Configure Apache Host

Add the following directives inside the <VirtualHost> tags in the file /etc/apache2/sites-available/000-default.conf:

1
2
3
4
5
6
7
8
Alias /webdav /var/www/webdav
<Location /webdav>
DAV On
AuthType Basic
AuthName "WebDAV"
AuthUserFile /etc/apache2/webdav.users
Require valid-user
</Location>

Step 4: Create user for WebDAV

Use the htpasswd utility to create a user for WebDAV accessing:

1
sudo htpasswd -c /etc/apache2/webdav.users your_username

Step 5: Restart Apache

Restart apache2 to apply the change:

1
sudo systemctl restart apache2

If you encounter some error message like below when restarting apache.service:

1
Address already in use: AH00072: make_sock: could not bind to address...

Please check the processes or services listening on the port that Apache is configured to use.

We can open Web browser and type http:/server_ip_or_domain/webdav to check the connection and WebDAV availability. Enter the user and password in the pop-up window, then you will access the directory we created.

Finally, Zotero could synchronize the documents with the local server at a fast speed. (树莓派吃灰属性 -1 😆)