- 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
- Apache
- Apache Configuration
- Rebuilding and Securing Apache
- WebDAVmod_dav
- Streaming MP3smod_mp3
- Summary
- 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
Streaming MP3s—mod_mp3
If you've been using iTunes, you've probably got quite a collection of MP3 files that have been building up on your drive. Rather than taking the MP3s with you wherever you go, you can create your own Internet radio station and broadcast music to your computer at work, home, or wherever your MP3s aren't. Using the Apache mod_mp3 module, you can create a Shoutcast-compatible streaming MP3 server in a matter of minutes. Of course, it goes without saying that anyone who listens to your streams has a legitimate copy of the music. Absolutely no sarcasm intended. None.
Installing mod_mp3 only takes a few minutes of time. Download the latest release from http://www.modmp3.com/, and then decompress the archive:
[primal:~/mod_mp3] jray% tar zxf mod_mp3-0.19.tar.gz
Next, cd into the distribution directory, and use make install to compile the module:
[primal:~/mod_mp3] jray% cd mod_mp3-0.19/ [primal:~/mod_mp3/mod_mp3-0.19] jray% make install apxs -o mod_mp3.so -c directives.c ice.c load.c mod_mp3.c shout.c utility.c o gg.c common.c cc -DDARWIN -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite -g -O3 -pipe -DHARD_SERVER_LIMIT=1024 -DEAPI -DSHARED_MODULE -I/usr/include/httpd -c directives.c cc -DDARWIN -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite -g -O3 -pipe -
DHARD_SERVER_LIMIT=1024 -DEAPI -DSHARED_MODULE -I/usr/include/httpd -c ice.c cc -DDARWIN -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite -g -O3 -pipe -
DHARD_SERVER_LIMIT=1024 -DEAPI -DSHARED_MODULE -I/usr/include/httpd -c load.c
Although the included installation instructions say to use make install to install the module, this does not work correctly under Mac OS X. Use sudo apxs -i -a -n 'mp3' mod_mp3.so to complete the process:
[primal:~/mod_mp3/mod_mp3-0.19] jray% sudo apxs -i -a -n 'mp3' mod_mp3.so cp mod_mp3.so /usr/libexec/httpd/mod_mp3.so chmod 755 /usr/libexec/httpd/mod_mp3.so [activating module `mp3' in /private/etc/httpd/httpd.conf]
The MP3-streaming module is now installed and ready for use.
Configuring mod_mp3
The mod_mp3 module is activated by setting up an Apache virtual host that will serve as the contact point for iTunes or any other streaming MP3 client. There are two ways to approach this—either by using a name-based or IP-based host, as we've already seen, or using a virtual host running on a port address rather than the standard Web server port 80. We shall use the latter.
There are a handful of directives used to control the mod_mp3 streaming features. These are documented in Table 27.4.
Table 27.4. These Directives Control mod_mp3's Capability to Stream Music.
| Directive | Purpose |
| MP3 <file or pathname> | Adds an MP3 file or directory containing MP3 files to the list of files to be served. |
| MP3Engine <on | off> | Turns on the streaming engine. |
| MP3CastName <stream name> | Sets a name for the streaming music collection. |
| MP3Genre <stream genre> | Sets a music genre for the stream. |
| MP3Random <on | off> | Randomizes the order that MP3 files will be served. |
| MP3Loop <on | off> | Loops through the music files indefinitely. |
| MP3LimitPlayConnections | The number of simultaneous streaming connections that <connection limit> will be supported. |
| MP3ReloadRequest <on | off> | If turned on, mod_mp3 will reload all files with each request. This is useful if you're adding to the available files during the broadcast. |
| MP3Playlist | Accepts the name of a file that contains a list of MP3 <pla y list file> filenames. |
| MP3Cache <on | off> | When on, the module will attempt to cache all MP3 files in memory. This can speed up the server, but will likely take up waaaay too much memory if you have more than a handful of files. |
Use these directives, coupled with a virtual host, to set up and start streaming. The following is a typical sample virtual host entry for the /etc/httpd/httpd.conf file:
1: Listen 8000 2: <VirtualHost music.poisontooth.com:8000> 3: ServerName music.poisontooth.com 4: MP3Engine On 5: MP3CastName "Johns Tunes" 6: MP3Genre "Hard Rock and 80s" 7: MP3 /Users/jray/Music 8: MP3Random On 9: Timeout 1200 10: </VirtualHost>
Line 1 sets the port number for listening to incoming streaming requests. The default Web port is 80, so if you're using the hostname for a Web site as well as streaming music, be sure to pick a different port.
Line 2 sets up the virtual host and port number for connections. Line 4 turns on MP3 support, and Lines 5 and 6 set some identifying information for the streaming server.
Line 7 adds a directory containing MP3 files to the stream (you can add as many MP3 directives as you'd like). Line 8 randomizes the playback order; and line 9 sets a high timeout so that connections are properly serviced.
Restart Apache to turn on your new mod_mp3-streaming server: /usr/sbin/apachectl restart.
To access your new MP3 server using iTunes, select Open Stream (Command+U) and enter the URL of your MP3 virtual host. The sample mod_mp3 configuration used in this chapter would be referenced with the URL http://music.poisontooth.com:8000, as seen in Figure 27.6.
Figure 27.6 Open the Apache-served MP3 stream from within iTunes
Summary | Next Section

Account Sign In
View your cart