27/11/2018

Edit php files via WebDAV

One thing I really like is to give developers exactly the right access they need for work, nothing more nothing less.

For example for LAMP stacks I usually avoid using unsecure protocols like ftp or network shares to give developers access to files, I hate unnecessary products (for example management web interfaces) which add complexity instead of reduce it, and I prefer not to use scp because I don’t like to add new shells to the system and chroot is usually a pain in the ass.

One protocol that usually fits perfectly these needs imho is WebDAV, it’s easy to setup, it’s robust, it’s well known, it’s network friendly (it uses the same protocol and ports used to render sites, which means also no troubles with file ownership), it can be easily used via TLS, and don’t need chroot or other complex setups.
Obviously It’s not a good idea to activate WebDAV to production or at least to virtualhosts accessible from web, but in general I think it’s a very covenient way to give people the right access they need to work.

There’s only one issue regarding this method, usually LAMP setups require that php files will be handled by php itself, that create problems even for a simple GET, which returns an empty file.

One easy way to fix this issue with Apache is to add “SetHadler none” directive to prevent php from handling requests for those files.
Obviously you can do this inside a specific virtualhost not used for rendering content, otherwise php will never be processed and pages will never work…

After reloading the webserver configuration webdav requests start working.