FreeBSD7.1RにIcecast2をインストール

インストール

%su
Password:
# cd /usr/ports/audio/icecast2
# make install clean
# rehash
  • rehash は単なる癖。

/etc/rc.conf の末尾にでも下記を追加。

icecast_enable="YES"

アクセス権限を持つユーザを作成する。後の設定で使うのでどこかにメモしておくこと。

# pw groupadd -n icecast
# pw useradd -n icecast -g icecast -s /sbin/nologin -d nonexistent
# passwd icecast

設定

まず、ログファイルを保管するディレクトリを作成し、サンプル設定ファイルをコピーする。

# mkdir /var/log/icecast
# chmod 777 /var/log/icecast
# cd /usr/local/etc
# cp icecast.xml.sample icecast.xml
# chmod 666 icecast.xml

下記のようにicecast.xml を書き換える。

Limits

<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>
        <!-- If enabled, this will provide a burst of data when a client 
             first connects, thereby significantly reducing the startup 
             time for listeners that do substantial buffering. However,
             it also significantly increases latency between the source
             client and listening client.  For low-latency setups, you
             might want to disable this. -->
        <burst-on-connect>1</burst-on-connect>
        <!-- same as burst-on-connect, but this allows for being more
             specific on how much to burst. Most people won't need to
             change from the default 64k. Applies to all mountpoints  -->
        <burst-size>65535</burst-size>
    </limits>

Authentication

    <authentication>
        <!-- Sources log in with username 'source' -->
        <source-password>hackme</source-password>・・・・・・・・・・※変更①
        <!-- Relays log in username 'relay' -->
        <relay-password>hackme</relay-password>・・・・・・・・・・※変更②

        <!-- Admin logs in with the username given below -->
        <admin-user>admin</admin-user>・・・・・・・・・・※変更③
        <admin-password>hackme</admin-password>・・・・・・・・・・※変更④
    </authentication>

*変更①:hackme に、ices等の音源プログラムからicecastへデータを送る際に使用するパスワードを記述。適時変更しておく。

*変更②:hackme に、他サーバとのリレーを行う際にしようするパスワードを記述。ここでは使わない。

*変更③④:admin、hackme に、管理者用のユーザ名とパスワードを記述。なんでもよい。

Ahoutcast-mount

    <!-- set the mountpoint for a shoutcast source to use, the default if not
         specified is /stream but you can change it here if an alternative is
         wanted or an extension is required
    <shoutcast-mount>/live.nsv</shoutcast-mount>
    -->
  • 初期状態で全てコメントアウトされている。

YP Directory

    <!-- Uncomment this if you want directory listings -->
    <!--
    <directory>
        <yp-url-timeout>15</yp-url-timeout>
        <yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
    </directory>
     -->
  • 初期状態で全てコメントアウトされている。

Misc Server Settings

    <!-- This is the hostname other people will use to connect to your server.
    It affects mainly the urls generated by Icecast for playlists and yp
    listings. -->
    <hostname>localhost</hostname>・・・・・・・・・・※変更⑤

    <!-- You may have multiple <listener> elements -->
    <listen-socket>
        <port>8000</port>・・・・・・・・・・※変更⑥
        <!-- <bind-address>127.0.0.1</bind-address> -->
        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->
    </listen-socket>
    <!--
    <listen-socket>
        <port>8001</port>
    </listen-socket>
    -->
  • 変更⑤:ドメイン名を記述する。www.vdobv.com など。
  • 変更⑥:ポート番号を記述する。変更する場合はルータ等の穴空けを忘れずに。

Relay Settings

    <!--<master-server>127.0.0.1</master-server>-->
    <!--<master-server-port>8001</master-server-port>-->
    <!--<master-update-interval>120</master-update-interval>-->
    <!--<master-password>hackme</master-password>-->

    <!-- setting this makes all relays on-demand unless overridden, this is
         useful for master relays which do not have <relay> definitions here.
         The default is 0 -->
    <!--<relays-on-demand>1</relays-on-demand>-->

    <!--
    <relay>
        <server>127.0.0.1</server>
        <port>8001</port>
        <mount>/example.ogg</mount>
        <local-mount>/different.ogg</local-mount>
        <on-demand>0</on-demand>

        <relay-shoutcast-metadata>0</relay-shoutcast-metadata>
    </relay>
    -->
  • 初期状態で全てコメントアウトされている。

Mount Specific Settings

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

    -->
  • 初期状態で全てコメントアウトされている。

Misc Server Settings

    <fileserve>1</fileserve>

Path Settings

    <paths>
		<!-- basedir is only used if chroot is enabled -->
        <basedir>/usr/local/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>/usr/local/var/log/icecast</logdir>・・・・・・・・・・※変更⑦
        <webroot>/usr/local/share/icecast/web</webroot>・・・・・・・・・・※変更⑧
        <adminroot>/usr/local/share/icecast/admin</adminroot>・・・・・・・・・・※変更⑨
        <!-- <pidfile>/usr/local/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>
  • 変更⑦:ログファイル保存ディレクトリ。/var/log/icecast
  • 変更⑧:ウェブディレクトリ。変更しなくてよい。
  • 変更⑨:管理画面ディレクトリ。変更しなくてよい。
  • 変更⑩:プロセスをkillしたい場合などに使う。放置。

Logging Settings

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <!-- <playlistlog>playlist.log</playlistlog> -->
      	<loglevel>3</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 Settings

    <security>
        <chroot>0</chroot>
        <!--・・・・・・・・・※変更⑪
        <changeowner>
            <user>nobody</user>・・・・・・・・・・※変更⑫
            <group>nogroup</group>・・・・・・・・・・※変更⑬
        </changeowner>
        -->・・・・・・・・・※変更⑭
    </security>
</icecast>

  • 変更⑪⑭:コメントアウトされているので、取り除く。
  • 変更⑫⑬:OS管理ユーザ名。 今回の例で、は共に icecast を設定。

起動テスト

# /usr/local/etc/rc.d/icecast2 start

起動しているか確認してみる。

# ps aux | grep icecast

動いているならリブートしても起動するか確認。

# reboot
# ps aux | grep icecast

管理画面を表示

設定したポート番号にもよるが、ここでの例として、hostname が www.vdobv.com、ポート番号が 8000 と仮定した場合、次のようにブラウザのアドレス欄に入力して、画面が表示されれば正常。

  • ちなみに、本サーバには icecast をインストールしていないので、下記のアドレスでは動きません。
http://www.vdobv.com:8000/

音源プログラム Ices を使って icecast にデータを送ってみる

freebsd7.1r/icecast2.txt · 最終更新: 2008/12/19 14:40 by vdobv
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0