Apache2 to provide streaming audio (MIPSel)

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 02:15, 15 September 2006 by Ramuk (Talk | contribs)

Jump to: navigation, search

Originally by AndreGauthier from linkstationwiki.org

Contents

Overview

I have been using Apache2 with mod_musicindex to provide streaming audio to the various computers around my house and to enable me to access my music collection from work (my ADSL is confiured with static IP and did port forwarding to my laptop). On aquisition of my nice shiny new Linkstation2 it seemed only obvious that I move this functionality to the Linkstation so that I don't have to leave my laptop on all day when I am at work.


Apache Build

Pre-Requisites

  1. Linkstation2
  2. mipsel-openlink-052b.zip (from the downloads section and installed as per README).
  3. mipsel-tools-2.tgz (from the downloads section and inststalled with the install.sh).
  4. mipsel-screen-1.tgz (from the downloads section and inststalled with the install.sh). (NOT REQUIRED but the compile takes ages and this helps if you get disconnected when it is running).
  5. /usr/bin/sort extracted from the debian package coreutils-5.2.1
  6. apache source httpd-2.0.55.tar.gz

This is now enough to compile apache2


Procedure

( I enable ssl to help bypassing content filters at work. I have also enabled proxy which allows me to proxy to internal server resources if they are available (like my laptop running tomcat and some of my development work))

  1. Extract httpd-2.0.55.tar.gz
  2. cd httpd-2.0.55
  3. ./configure --prefix=/mnt/hda/apache --enable-ssl --enable-proxy
  4. make
  5. make install
  6. WAIT AGES
  7. create an apache user and group in /etc/passwd and /etc/group respectively with the users home set to /mnt/hda/apache
  8. cd ~apache/conf
  9. edit httpd.conf to set ServerName to something appropriate set the User and Group directives to apache
  10. edit /etc/thttpd.conf and change the port to 8080 (I did this to make my life easier accessing the apache instance and also to hide the config interface from the net when I set port forwarding to the linkstation)
  11. run /etc/init.d/thttpd restart
  12. Start apache (cd ~apache/bin; ./apachectl start)
  13. Go to http:/<linkstation>/ and see the apache page.
  14. Create a start script in /etc/init.d (included below)
  15. cd /etc/rc.d/rc2.d
  16. ln -s ../init.d/apache S95apache
  17. cd /etc/rc.d/rc0.d
  18. ln -s ../init.d/apache K05apache
  19. cd /etc/rc.d/rc6.d
  20. ln -s ../init.d/apache K05apache

That should be a nice little apache2 install which will restart every reboot now.

Apache init script

#!/bin/sh
#
# apache - startup script for apache 
# This goes in /etc/init.d and gets run at boot-time.
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin
APACHE_HOME=/mnt/hda/apache

if ! [ -x $APACHE_HOME/bin/apachectl ]; then
       exit 0
fi

case "$1" in

   start)
         echo  "Start services: apache"
         $APACHE_HOME/bin/apachectl startssl
       ;;
   stop)
       echo  "Stop services: apache"
       $APACHE_HOME/bin/apachectl stop
       ;;
   restart)
       echo  "Restart services: apache"
       $APACHE_HOME/bin/apachectl restart
       ;;
   *)
       echo "usage: $0 { start | stop | restart}" >&2
       exit 1
       ;;

esac

exit 0



Build mod_musicindex

Pre-Requisites

  1. All of the above has been done
  2. download libapache-mod-musicindex_1.0.2.orig.tar.gz from http://www.parisc-linux.org/~varenet/musicindex/
  3. obtain required libraries


Required Libraries

I only wanted vorbis and mp3 support so this is all I have used. If you figure out all the dependencies for other codecs feel free to add them. The libraries were downloaded from my local debian mirror and I used alien -t <debfile> to convert them to tgz files which were extracted into the root of the link station.

* libid3tag0-0.15.1b.tgz

* libid3tag0-dev-0.15.1b.tgz

* libmad0-0.15.1b.tgz

* libmad0-dev-0.15.1b.tgz

* libogg0-1.1.3.tgz

* libogg-dev-1.1.3.tgz

* libvorbis0a-1.1.2.tgz

* libvorbis-dev-1.1.2.tgz

* libvorbisenc2-1.1.2.tgz

* libvorbisfile3-1.1.2.tgz


Procedure

  1. Extract libapache-mod-musicindex_1.0.2.orig.tar.gz
  2. cd libapache-mod-musicindex-1.0.2
  3. ./configure --with-apxs=/mnt/hda/apache/bin/apxs
  4. make
  5. make install
  6. Add LoadModule musicindex_module modules/mod_musicindex.so near the top of ~apache/conf/httpd.conf
  7. Add a Directory config for music index to the bottom of ~apache/conf/httpd.conf (see mine below).
  8. Create a directory ~apache/musicindex and do chmod 0777 ~apache/musicindex (this will be used to cache stuff so I didn't want it on the root filesystem).
  9. Create a directory ~apache/htdocs/musicindex and copy the contents of /usr/local/share/mod_musicindex/ into it.
  10. Restart apache


My Directory Config

Alias /music /mnt/hda/share/home_backup/media/mp3
<Directory /mnt/hda/share/home_backup/media/mp3>
   Options             Indexes MultiViews FollowSymlinks
   AllowOverride       Indexes
   MusicLister         On
   MusicSortOrder      album disc track artist title length bitrate freq filetype filename uri
   MusicFields         title artist length bitrate
   MusicAllowDownload  Off
   MusicAllowStream    On
   MusicAllowSearch    On
   #MusicRssItems       Off
   MusicPageTitle      BlackHole
   #MusicDefaultCss     nomadindex.css
   MusicDefaultDisplay HTML
   MusicIndexCache     file://mnt/hda/apache/musicindex
   #MusicIceServer      [ice.domain.my]:8000
   #MusicCookieLife     300
</Directory>


RSync

The home_backup was created from my laptop running Ubuntu after I installed rsync on to the link station. This allows me to regularly back up my laptop and rsync will only copy deltas which saves me loads of time.

  1. obtain rsync deb package
  2. run alien -t <debpackage>
  3. unpack the tgz into the root of the linkstation.