Icecast is a streaming server which sends audio streams in MP3 or Theora formats.

~ # emerge -pv icecast

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    ] media-libs/libogg-1.2.0  USE="-static-libs" 391 kB
[ebuild  N    ] media-libs/libvorbis-1.3.1  USE="-static-libs" 1,190 kB
[ebuild  N    ] media-libs/speex-1.2_rc1  USE="ogg sse -static-libs" 1,037 kB
[ebuild  N    ] media-libs/libtheora-1.1.1  USE="-doc encode -examples -static-libs" 1,859 kB
[ebuild  N    ] net-misc/icecast-2.3.2  USE="speex ssl theora -yp" 1,126 kB

Review for your environment then emerge icecast, wait a few minutes.

Configuring Icecast Server

Edit the /etc/icecast2/icecast.xml file as follows, this will create one listening area for the inbound stream and an connection side to send the stream out.

<icecast>
    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <threadpool>5</threadpool>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <burst-on-connect>1</burst-on-connect>
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <source-password>hackme</source-password>
        <relay-password>hackme</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>admin</admin-password>
    </authentication>

    <!-- This is the hostname other people will use to connect to your server.  -->
    <hostname>my.fqdn.tld</hostname>

    <!-- You may have multiple <listener> elements -->
    <listen-socket>
        <port>8000</port>
        <bind-address>1.2.3.4</bind-address>
    </listen-socket>
    <!--
    <listen-socket>
        <port>8001</port>
    </listen-socket>
    -->

    <!-- Only define a <mount> section if you want to use advanced options, like alternative usernames or passwords -->
    <!--
    <mount>
        <mount-name>/example-complex.ogg</mount-name>

        <username>othersource</username>
        <password>hackmemore</password>

        <max-listeners>1</max-listeners>
        <dump-file>/tmp/dump-example1.ogg</dump-file>
        <burst-size>65536</burst-size>
        <fallback-mount>/example2.ogg</fallback-mount>
        <fallback-override>1</fallback-override>
        <fallback-when-full>1</fallback-when-full>
        <intro>/example_intro.ogg</intro>
        <hidden>1</hidden>
        <no-yp>1</no-yp>
        <authentication type="htpasswd">
                <option name="filename" value="myauth"/>
                <option name="allow_duplicate_users" value="0"/>
        </authentication>
        <on-connect>/home/icecast/bin/stream-start</on-connect>
        <on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
    </mount>

    <mount>
        <mount-name>/auth_example.ogg</mount-name>
        <authentication type="url">
            <option name="mount_add"       value="http://myauthserver.net/notify_mount.php"/>
            <option name="mount_remove"    value="http://myauthserver.net/notify_mount.php"/>
            <option name="listener_add"    value="http://myauthserver.net/notify_listener.php"/>
            <option name="listener_remove" value="http://myauthserver.net/notify_listener.php"/>
        </authentication>
    </mount>

    -->

    <fileserve>1</fileserve>

    <paths>
		<!-- basedir is only used if chroot is enabled -->
        <basedir>/usr/share/icecast</basedir>

        <!-- Note that if <chroot> is turned on below, these paths must both
             be relative to the new root, not the original root -->
        <logdir>/var/log/icecast</logdir>
        <webroot>/usr/share/icecast/web</webroot>
        <adminroot>/usr/share/icecast/admin</adminroot>
        <!-- <pidfile>/usr/share/icecast/icecast.pid</pidfile> -->

        <!-- Aliases: treat requests for 'source' path as being for 'dest' path
             May be made specific to a port or bound address using the "port"
             and "bind-address" attributes.
          -->
        <!--
        <alias source="/foo" dest="/bar"/>
          -->
        <!-- Aliases: can also be used for simple redirections as well,
             this example will redirect all requests for http://server:port/ to
             the status page
          -->
        <alias source="/" dest="/status.xsl"/>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <!-- <playlistlog>playlist.log</playlistlog> -->
      	<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
      	<logsize>10000</logsize> <!-- Max size of a logfile -->
        <!-- If logarchive is enabled (1), then when logsize is reached
             the logfile will be moved to [error|access|playlist].log.DATESTAMP,
             otherwise it will be moved to [error|access|playlist].log.old.
             Default is non-archive mode (i.e. overwrite)
        -->
        <!-- <logarchive>1</logarchive> -->
    </logging>

    <security>
        <chroot>0</chroot>
        <changeowner>
            <user>icecast</user>
            <group>nogroup</group>
        </changeowner>
    </security>
</icecast>

We choose to disable almost all modules possible, here is a snip from lighttpd.conf

server.modules = (
  "mod_access",
  "mod_status",
  "mod_simple_vhost",
  "mod_accesslog"
)

# we comment this out because everything from the CDN is static
#static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")

We also had to update the mime-types so lighttpd would return scripting language files as text. We added these lines to the mime-types.conf file distributed with lighttpd.

".dmg"          =>      "application/x-apple-diskimage",
# return these scripts as text
".php"          =>      "text/plain",
".pl"           =>      "text/plain",
".sh"           =>      "text/plain",