- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Introduction
- Part I: Introduction to Mac OS X
- Chapter 1. Mac OS X Component Architecture
- Chapter 2. Installing Mac OS X
- Chapter 3. Mac OS X Basics
- Chapter 4. The Finder: Working with Files and Applications
- Chapter 5. Running Classic Mac OS Applications
- Part II: Inside Mac OS X
- Chapter 6. Native Utilities and Applications
- Chapter 7. Internet Communications
- Chapter 8. Installing Third-Party Applications
- Part III: User-Level OS X Configuration
- Chapter 9. Network Setup
- Chapter 10. Printer and Font Management
- Chapter 11. Additional System Components
- Part IV: Introduction to BSD Applications
- Chapter 12. Introducing the BSD Subsystem
- Chapter 13. Common Unix Shell Commands: File Operations
- Part V: Advanced Command-Line Concepts
- Chapter 14. Advanced Shell Concepts and Commands
- Chapter 15. Command-Line Applications and Application Suites
- Chapter 16. Command-Line Software Installation
- Chapter 17. Troubleshooting Software Installs, and Compiling and Debugging Manually
- Chapter 18. Advanced Unix Shell Use: Configuration and Programming (Shell Scripting)
- Part VI: Server/Network Administration
- Chapter 19. X Window System Applications
- Chapter 20. Command-Line Configuration and Administration
- Chapter 21. AppleScript
- Chapter 22. Perl Scripting and SQL Connectivity
- Chapter 23. File and Resource Sharing with NetInfo
- Chapter 24. User Management and Machine Clustering
- Chapter 25. FTP Serving
- Chapter 26. Remote Access and Administration
- Chapter 27. Web Serving
- Part VII: Server Health
- Chapter 28. Web Programming
- Chapter 29. Creating a Mail Server
- Chapter 30. Accessing and Serving a Windows Network
- Chapter 31. Server Security and Advanced Network Configuration
- Chapter 32. System Maintenance
- Appendix A. Command-Line Reference
- Appendix B. Administration Reference
WebDAV—mod_dav
Something that Apple hasn't advertised with Mac OS X is the integration of WebDAV as a native file-sharing format. WebDAV (Distributed Authoring and Versioning) is a relatively new protocol that operates on top of HTTP. What makes this attractive is the fact it doesn't require additional inetd or system daemons to be present.
WebDAV is entirely cross-platform, is integrated into the Windows operating system, and supported natively in software such as Macromedia Dreamweaver as well. Using WebDAV, you can distribute authoring and editing Web sites across a number of different computers and operating systems. Best of all, WebDAV is easy to use and, because it operates through Apache, the same configuration directives you've already seen can apply directly to its setup.
Installing and Configuring WebDAV
You can download the WebDAV Apache module (mod_dav) from www.webdav.org/mod_dav/. Installing WebDAV is an excellent example of a typical Apache module compilation.
First, unarchive and uncompress the software:
[primal:~] jray% tar zxf mod_dav-1.0.2-1.3.6.tar.gz
Next, configure the application. You should use the --with-apxs directive to enable automatic configuration and installation of the Apache module:
[primal:~/mod_dav-1.0.2-1.3.6] jray% ./configure --with-apxs creating cache ./config.cache checking for gcc... no checking for cc... cc checking whether the C compiler (cc ) works... yes checking whether the C compiler (cc ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether cc accepts -g... yes checking for ranlib... ranlib
Finally, make and install the module:
[primal:~/mod_dav-1.0.2-1.3.6] jray% sudo make install cc -c -I/usr/include/httpd -I/usr/include/httpd/xml -g -O2 -DDARWIN -DUSE_HSREGEX-DUSE_EXPAT -I../lib/expat-lite -g -O3 -pipe-DHARD_SERVER_LIMIT=1024 -DEAPI
-DSHARED_MODULE dav_props.c -o dav_props.o ... cp libdav.so /usr/libexec/httpd/libdav.so chmod 755 /usr/libexec/httpd/libdav.so [activating module `dav' in /private/etc/httpd/httpd.conf]
To finish the configuration and activation of WebDAV service on your Apache server, you need to create a directory that will hold WebDAV lock files and then turn on the service for a particular directory or location.
Use the DAVLockDB directive to set the directory and base filename for WebDAV's lockfiles. This should fall anywhere after the LoadModule/AddModule lines in the /etc/httpd/httpd.conf file:
DAVLockDB /var/tmp/davlock
This example specifies that the directory /var/tmp will be used to hold lock files, and that davlock will be the base filename for the lock files. Be sure to include the base filename, not just a directory name. If the lockfile is not properly set, mod_dav will start, but won't operate correctly.
Now, choose one of the directory or container objects that will support WebDAV service and add the DAV On directive:
<Directory "/Library/WebServer/Documents">
DAV On
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
You should limit access to the DAV services using the same require directive in the standard Apache configuration. WebDAV relies on the HTTP protocol to authenticate users for editing. This means you will need to create a password file just like we did earlier. Unlike the previous example, however, a valid user will be required only when performing a modification to the file system. To create this sort of selective authentication, we'll use the Limit directive. For example, the following configuration file fragment defines an authentication scheme and limits it to the operations that WebDAV uses to add and update files.
AuthType Basic
AuthName "The Poisontooth Webserver"
AuthUserFile /Users/jray/webpasswords
<Limit PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require valid-user
</Limit>
To finish things up, just combine the authentication block with the resource that WebDAV support has been enabled (DAV On):
1: <Directory "/Library/WebServer/Documents"> 2: DAV On 3: Options Indexes FollowSymLinks MultiViews 4: AllowOverride None 5: Order allow,deny 6: Allow from all 7: AuthType Basic 8: AuthName "The Poisontooth Webserver" 9: AuthUserFile /Users/jray/webpasswords 10: <Limit PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> 11: Require valid-user 12: </Limit> 13: </Directory>
Line 1 sets up the directory to WebDAV enable. This can be a directory that is already defined in the main Apache http.conf or one of the user configuration files.
Line 2 turns on DAV support, and lines 3 through 6 are standard directory security directives—not WebDAV related.
Lines 7 through 9 set up basic HTTP authentication. This will be used to authenticate potential WebDAV clients. Lines 10–12 limit the HTTP authentication to only those actions that would be triggered by a WedDAV client.
There's still one small thing that needs to be adjusted before WebDAV can be used—the permissions on the directory that has DAV support enabled. Because WebDAV is nothing more than an extension to Apache, it has no more user rights than the Apache server process. This means that if Apache can't write to a resource (that is, it isn't owned by www or isn't set to world-writable), WebDAV won't be able to modify the resource either. To make a directory editable using DAV, you must use chown to modify the file and directory ownership. Type chown -R www:admin <directory to DAV-enable> and you're done!
Restart Apache (/usr/sbin/apachectl restart) to begin using WebDAV.
Mounting WebDAV Shares
First, from within a Finder window, use the Go menu to choose Connect to Server (Command+K). The dialog box shown in Figure 27.4 will appear.
Figure 27.4 Use the Connect to Server menu item to connect to WebDAV-enabled servers.
Fill in the URL of the directory with DAV access in the Address field. This should be the Web path to the resource, not the actual file path on the server. In the screenshot shown, the main root directory of the Web server has been enabled, so the URL given is just set to the main Web site URL. When satisfied that your settings are correct, click Connect. You will be prompted for a username and password for the resource. Use the username/password pair defined with htpasswd.
After a few seconds, the remote site should be mounted as if it were a local drive on your computer.
Using WebDAV on Windows
Like Mac OS X, WebDAV is integrated into recent releases of the Windows operating system. To access a WebDAV share from your Linux Web server, you must create a new Network Place.
Double-click My Network Places to open the Network Places window. Next, double-click Add Network Place to start the Network Place wizard, as seen in Figure 27.5.
Figure 27.5 The Network Place connection wizard will help set up a WebDAV resource in Windows.
Fill in the URL of the WebDAV resource, and then click Next. As with Mac OS X, you will be prompted for the username and password that were set using htpasswd. Click Next to finish and mount the resource.
WebDAV support is an integral part of Mac OS X and Windows, and can be used to unite a multiplatform environment for collaboration on Web sites and other projects. In a pinch, WebDAV can even serve as a file server for things other than Web-related files.
That's enough work for now. On to something a bit more entertaining—streaming audio from Apache!
Streaming MP3smod_mp3 | Next Section

Account Sign In
View your cart