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.



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

    <!-- You may have multiple <listener> elements -->

    <!-- Only define a <mount> section if you want to use advanced options, like alternative usernames or passwords -->


        <authentication type="htpasswd">
                <option name="filename" value="myauth"/>
                <option name="allow_duplicate_users" value="0"/>

        <authentication type="url">
            <option name="mount_add"       value=""/>
            <option name="mount_remove"    value=""/>
            <option name="listener_add"    value=""/>
            <option name="listener_remove" value=""/>



		<!-- basedir is only used if chroot is enabled -->

        <!-- Note that if <chroot> is turned on below, these paths must both
             be relative to the new root, not the original root -->
        <!-- <pidfile>/usr/share/icecast/</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"/>

        <!-- <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> -->


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

server.modules = (

# 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",