1. Download and install the latests Apache 2.2 release for Windows. In my case, I downloaded apache_2.2.4-win32-x86-no_ssl.msi and installed it for "All Users, on port 80, as a Service", in C:\Program Files\Apache Software Foundation\Apache2.2\.
2. Create a C:/Program Files/Apache Software Foundation/Apache2.2/var directory, right click on it, select the Security tab, go to the Advanced Parameters, select the Owner tab and select Administrator as owner.
Note: According to this article in the Microsoft Knowledge Base:
If the Security tab is not available, and if you cannot configure permissions for users and groups, either the file or folder that you want to apply permissions to is not an NTFS drive, or simple file sharing is enabled. To troubleshoot, follow these steps
- Verify that the file or folder that you want to apply permissions to is an NTFS drive. You can set permissions only on drives that are formatted to use NTFS.
- By default, simplified sharing is enabled in Windows XP unless you are on a domain. To work around this behavior, disable Simplified Sharing.
Disabling Simplified Sharing can be done as explained in the same article
3. Repeat the operation for C:/Program Files/Apache Software Foundation/Apache2.2/uploads.
4. Then execute the following command from apache bin directory: htdigest -c "C:/Program Files/Apache Software Foundation/Apache2.2/user.passwd" DAV-upload admin.
5. Edit C:/Program Files/Apache Software Foundation/Apache2.2/httpd.conf, activate the following modules: mod_dav, mod_dav_fs, mod_setenvif, mod_alias, mod_auth_digest, mod_authn_file. Uncomment the line: #Include conf/extra/httpd-dav.conf.
6. Restart Apache
7. Download and install Cadaver, a command-line WebDAV client for unix. Wait, it's a Unix tool... The good news is that it has been ported under Cygwin. Download Cygwin and install the cadaver package!
8. Open cygwin and launch: cadaver http://localhost/uploads
pthivent@pthivent-laptop ~ $ echo "bar" > foo.txt
pthivent@pthivent-laptop ~ $ cadaver http://localhost/uploads
Authentication required for DAV-upload on server `localhost':
Username: admin
Password:
dav:/uploads/> put foo.txt
Uploading foo.txt to `/uploads/foo.txt':
Progress: [=============================>] 100.0% of 401 bytes succeeded.
dav:/uploads/> ls
Listing collection `/uploads/': succeeded.
*foo.txt 4 Aug 10 00:16
dav:/uploads/>
Ok, dav and authentication are working, authentication a bit too much actually. I should be able to browse without authentication. Let's have a look at apache access.log. When executing cadaver http://localhost/uploads, the following entries are logged in the access file:
127.0.0.1 - - [10/Aug/2007:02:22:37 +0200] "OPTIONS /uploads/ HTTP/1.1" 200 -
127.0.0.1 - - [10/Aug/2007:02:22:37 +0200] "PROPFIND /uploads/ HTTP/1.1" 401 401
But in C:/Program Files/Apache Software Foundation/Apache2.2/extra/httpd-dav.conf, only GET and OPTIONS don't require authentication.
9. I decide to add PROPFIND to the LimitExcept list, restart Apache and
dav:/uploads/> put bar.txt
Uploading bar.txt to `/uploads/bar.txt':
Progress: [=============================>] 100.0% of 401 bytes
Authentication required for DAV-upload on server `localhost':
Username: admin
Password:
succeeded.
dav:/uploads/>
10. Let's try a Windows "Web Folder" now, just for the fun. Go to your "Windows network places" and "Add a network place" pointing on http://localhost/uploads... Open the location, browse it. Try to create a file/directory. Provide the required credentials :)
11. Finally, open http://localhost/uploads in IE.
Forbidden
You don't have permission to access /uploads/ on this server.
Strange, this is not what I was expecting... Let's check the error.log :
[Fri Aug 10 02:36:35 2007] [error] [client 127.0.0.1] Directory index forbidden by Options directive: C:/Program Files/Apache Software Foundation/Apache2.2/uploads/
12. Well, that's perfectly clear. Let me authorize this in the httpd-dav.conf with an Options Indexes in the uploads Directory directive.
13. Restart Apache... open IE, check again and... browse your directory this time!
Just to summarize, below a diff between the original httpd.conf and the modified one:
pthivent@pthivent-laptop /cygdrive/c/Program Files/Apache Software Foundation/Apache2.2/conf $ diff httpd.conf default/httpd.conf
71c71
< LoadModule auth_digest_module modules/mod_auth_digest.so
---
> #LoadModule auth_digest_module modules/mod_auth_digest.so
84,85c84,85
< LoadModule dav_module modules/mod_dav.so
< LoadModule dav_fs_module modules/mod_dav_fs.so
---
> #LoadModule dav_module modules/mod_dav.so
> #LoadModule dav_fs_module modules/mod_dav_fs.so
469c469
< Include conf/extra/httpd-dav.conf
---
> #Include conf/extra/httpd-dav.conf
pthivent@pthivent-laptop /cygdrive/c/Program Files/Apache Software Foundation/Apache2.2/conf $
And this is a diff between the original httpd-dav.conf and the mofified one:
pthivent@pthivent-laptop /cygdrive/c/Program Files/Apache Software Foundation/Apache2.2/conf $ diff extra/httpd-dav.conf default/httpd-dav.conf
20d19
< Options Indexes
34c33
< <LimitExcept GET OPTIONS PROPFIND>
---
> <LimitExcept GET OPTIONS>
pthivent@pthivent-laptop /cygdrive/c/Program Files/Apache Software Foundation/Apache2.2/conf $
Now, let's see how this works under Windows 2K.
8 comments: