designermonkey
designermonkey

Reputation: 1108

How to allow writing to files via Apache and WebDAV

I am having trouble understanding how I can get to edit files on a WebDAV setup. I have set up the Auth correctly, as verified by loads of online tutorials, yet there are some files like .htaccess which I can't edit.

The contents of the VirtualHost setup are

<VirtualHost *:80>

        ServerAdmin xxx
        ServerName xxx

        DocumentRoot /data/www/vhosts/xxx
        <Directory /data/www/vhosts/xxx>
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        <Location />
                DAV On
                AuthType Basic
                AuthName "WebDAV Access"
                AuthUserFile /data/www/.htpasswd-webdav
                Require valid-user
        </Location>

</VirtualHost>

I've generated the correct username in the file too, and I can log in successfully and see all the files. Like I say, the problem is that certain files are unreadable and unwritable, the main culprits being .htaccess and .gitignore.

I have set the permissions on all files to 664 and all folders to 775 and a user:group of xxx:www-data. The reason being that this allows PHP to read/write the files ok, and our remote login user xxx to do the same without permissions issues.

Is there something specific I need to do to allow reading writing to these hidden dot files? I'm completely stumped, as most tutorials I've read are telling me that if I don't set the rights on dot files to root:root then they will be writable. I am using a Mac to connect to the WebDAV service, which runs on Ubuntu, if this makes any difference

Just for clarity, all of the xxx in this question is to hide info.

Upvotes: 4

Views: 23076

Answers (2)

Bas
Bas

Reputation: 11

Also check the permissions of /data/www/ itself. It should be writable for the apache user.

Upvotes: 1

designermonkey
designermonkey

Reputation: 1108

So it seems that I can allow access to specific files using the below

<Files .htaccess>
 order allow,deny
 deny from all
</Files>

I forgot that .htaccess files are blocked over HTTP by default.

EDIT:

The final working setup, to make all files writeable in the webdav environment, with Digest secure authentication is:

<VirtualHost *:80>

        ServerAdmin xxx
        ServerName www.domain.name

        DocumentRoot xxx
        <Directory xxx>
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        <FilesMatch "\.(htaccess|php)$">
        Order allow,deny
        allow from all
        ForceType text/plain
    </FilesMatch>

        <Location />
                DAV On

                AuthType Digest
                AuthName "Webdav Access"
        AuthDigestDomain / http://www.domain.name/

        AuthDigestProvider file
                AuthUserFile /data/www/digest.users
                Require valid-user

        php_value engine off
        </Location>

</VirtualHost>

I hope this helps someone else. It took days to find all this info out on the web.

Upvotes: 5

Related Questions