Coming back to Linux after years away and trying to set up mod_dav to serve myself the /var/www directory to do some web development. Should be easy, but this is giving me a hard time. Running CentOS 7 on an AWS Lightsail instance. Installed httpd and mod_ssl via yum and performed what should have been an easy config.

In /etc/httpd/conf.d/ssl.conf global section:

DavLockDB /var/www/DavLock

In <VirtualHost>:

Alias /webdav /var/www
<Directory /var/www>
    DAV On
    AuthType Basic
    AuthName "webdav"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user

I have done a chown 777 apache:apache on /var/www. I have run systemctl restart apache and rebooted, but no luck.

Now for the weird stuff. I can get successfully log in from a Windows 10 client and get a listing of directories in /var/www on <mydomain>/webdav. I can list and open files in /var/www, but not in /var/www/html. I cannot create files or directories.

In ssl_error.log:

[Sun May 24 20:01:49.254447 2020] [dav:error] [pid 16108] [client <masked ip>] The locks could not be queried for verification against a possible "If:" header.  [500, #0]
[Sun May 24 20:01:49.254463 2020] [dav:error] [pid 16108] [client <masked ip>] Could not open the lock database.  [500, #400]
[Sun May 24 20:01:49.254473 2020] [dav:error] [pid 16108] (13)Permission denied: [client <masked ip>] Could not open property database.  [500, #1]

OK. So the permissions aren't right to create the lock database. But ls -la returns this:

drwxr-xr-x.  4 apache apache   33 May 24 19:49 www

And to double dummy-check, ps -aux shows httpd is running as user apache, minus the startup process it needs to bind the ports:

root     16107  0.0  1.4 249968  7416 ?        Ss   20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16108  0.0  1.1 250236  5652 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16109  0.0  0.7 249968  3644 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16110  0.0  0.7 249968  3644 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16111  0.0  0.7 249968  3644 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16112  0.0  1.1 250236  5656 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND
apache   16116  0.0  0.7 249968  3656 ?        S    20:01   0:00 /usr/sbin/httpd -DFOREGROUND

What the heck am I missing?

  • Ok, so part one is figured out. SELinux was preventing Apache from writing the lock file. Anyone else who has this problem, the changes necessary are here: server-world.info/en/note?os=CentOS_7&p=httpd&f=12 Still need to figure out why I cannot see files in the html folder, though...
    – delimeat52
    May 25 '20 at 8:51
  • So it seems to only affect the /var/www/html folder. I can successfully access and edit /var/www/cgi-bin. Is it because /var/www/html is the root for the virtual host and WebDAV is serving an upstream directory as an alias? I've tried adding another Alias and another <Directory>, both of which did nothing.
    – delimeat52
    May 25 '20 at 9:02

So this was a two-parter:

  1. First, as I metioned in a comment above, SELinux was not allowing the Apache process to write the DavLock file. Instructions on how to correct this without disabling SELinux: https://server-world.info/en/note?os=CentOS_7&p=httpd&f=12

  2. Second, directory indexes cannot be on for any folder you want served via WebDAV. There was DirectoryIndex index.html in my main httpd.conf file and this was screwing things up. By adding the following to <Directory /var/www/html> block everything started working:

    <If "%{REQUEST_METHOD} != 'GET'">
        DirectoryIndex none
        DirectoryIndex index.htm index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.