- 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
Apache
Apache is an open source project developed by a worldwide group of volunteers known as the Apache group (www.apache.org). It is available on dozens of operating systems including Microsoft Windows. Apache's appeal comes from its flexibility and extensibility. The base server package excels at serving HTML, but to truly exploit the power of Apache, you can install a number of extension modules, including MP3 streaming servers, SSL security, Java Server Pages, and much more. With a total expenditure of $0, you can set up a secure e-commerce server that processes credit cards in real-time and delivers SQL database access.
Apache Versus Personal Web Sharing
If you're looking for the features of the Mac OS 8/9 personal Web server, look elsewhere. The Apache server under Mac OS X does not offer the Finder mode, nor does it offer the SimpleText to HTML conversion of the previous operating system. To place information online, you'll need to create HTML documents. This isn't difficult, but there is no direct upgrade path if you have a collection of SimpleText documents you've been serving off the Internet.
Although Mac OS 8/9 allowed you to use the primary address of your computer as the address for your Web site, the Mac OS X Web sharing system forces a URL based on your username. For example, if your computer's address is http://192.168.0.1 and your username is joeuser, your Web site address would be http://192.168.0.1/~joeuser. This change is due to the multiuser capabilities of Mac OS X. Regardless of how many users are on the system, each can have his or her personal Web site online, simultaneously. To use this feature, users must place their Web pages with the Site folder of their home directory. If you want a single server without usernames, a master Web site can be created by placing documents in the /Library/Webserver/Documents folder.
Regardless of whether Apache is being used for an entire Web site or a few personal pages, users can take advantage of the server's advanced features. A personal page can execute CGI applications, use embedded programming languages, and so on.
Capabilities
This chapter addresses the base features of Apache, but it also includes some interesting add-ons that will make your system into a Web serving powerhouse. There are literally hundreds of Apache modules available for download (http://modules.apache.org/), so we'll try and focus on a select few:
- mod_ssl — The standard for Web server security is SSL, the Secure Socket Layer. Through the use of OpenSSL and the mod_ssl module, Apache can be configured for completely secure transactions.
- mod_dav — Mac OS X supports built-in WebDAV (Distributed Authoring and Versioning) file system access. This open standard defines a file-sharing protocol based on standard HTTP. The cross-platform nature of WebDAV means both Macintosh and Windows users can access the same files, from the same server.
- mod_mp3 — Have an MP3 library? Want to stream it to the world? This module creates an MP3 stream accessible by any MP3 player supporting the Shoutcast protocol.
If you're not interested in these features, take a look at the other Apache modules available. It's best to install only the modules you really use. Additional modules can add overhead and potentially weaken the overall security of the server.
Activating Web Sharing
To activate Web sharing (and the Apache Web server), open the System Preferences application (Path: /Applications/System Preferences) and click the Sharing icon. You've seen this screen, shown in Figure 27.1, before.
Figure 27.1 Use the Sharing Preference panel to activate Apache.
Assuming the screen reads Web Sharing Off, click the Start button to start Apache. After a few seconds, the server status should change to Web Sharing On. Your Web pages are now online.
The Sharing button does two things. First, it configures the Mac OS X Server to start Apache when it boots. The /etc/hostconfig file is modified to read WEBSERVER=-YES-:
## # /etc/hostconfig ## # This file is maintained by the system control panels ## # Network configuration HOSTNAME=-AUTOMATIC- ROUTER=-AUTOMATIC- # Services AFPSERVER=-YES- APPLETALK=en1 AUTHSERVER=-NO- AUTOCONFIG=-YES- AUTODISKMOUNT=-REMOVABLE- AUTOMOUNT=-YES- CONFIGSERVER=-NO- IPFORWARDING=-NO- MAILSERVER=-NO- MANAGEMENTSERVER=-NO- NETBOOTSERVER=-NO- NISDOMAIN=-NO- TIMESYNC=-YES- QTSSERVER=-NO- SSHSERVER=-YES- WEBSERVER=-YES- APPLETALK_HOSTNAME="John Ray's Computer"
Second, it activates the Apache server with no need to reboot. You can start, stop, and restart Apache at any time using the /usr/sbin/apachectl utility. For example, to restart the server, type
$ /usr/sbin/apachectl restart
Table 27.1 documents all of the available apachectl options.
Table 27.1. The apachectl Administration Application Accepts These Commands
| Options | Functions |
| start | Start the Apache server. |
| stop | Stop the Apache server. |
| restart | Restart Apache. This is equivalent to stopping then starting the server. Current connections are closed. |
| fullstatus | Display a full status of the server. This requires lynx to be installed. |
| status | Display a summary of the server status. The lynx text browser is required. |
| graceful | Restart the server gracefully. Current connections are not dropped. |
| configtest | Check the configuration files for errors. Can be used regardless of the current server state. |
There is an interface problem that occurs with Apple's use of the Personal Web Sharing metaphor when it is applied to Apache. Each user has his or her own directory. When Web sharing is turned on for one user, it is activated for everyone.
If the computer is a multiuser system, you cannot be certain that Web sharing is on or off. The only ways to guarantee that your files aren't being displayed on the Web is to manually disable viewing files using Apache configuration directives, or to remove the files from your Site directory.
Apache Configuration | Next Section

Account Sign In
View your cart