Setting Up Shoutcast Server on Natty Narwhal Ubuntu 11.04

Setting Up Shoutcast Server on Natty Narwhal Ubuntu 11.04

Adduser shoucast

Adduser shoutcast

root@linuxbeatswindows:~# adduser shoutcast

Adding user `shoutcast’ …

Adding new group `shoutcast’ (1001) …

Adding new user `shoutcast’ (1001) with group `shoutcast’ …

Creating home directory `/home/shoutcast’ …

Copying files from `/etc/skel’ …

Assign password to shoutcast user

#passwd shoutcast

If the shoutcast home directory is not created, create it

mkdir /home/shoutcast

Download and Extract Packages

Shoutcast requires two packages:

sc_trans_posix_040.tgz

sc_serv_1.9.8-Linux.tar.gz

Download sc_trans_posix_040.tgz and sc_serv_1.9.8-Linux.tar.gz packages

Copy the packages to the /home shoutcast directory

Chage ownership of the package to shoutcast if necessary.

# chown shoutcast:shoutcast sc_trans_posix_040.tgz

This is necessary if you have use root user to download the package.

In my case, I switch user to shoutcast and extract the paackages.

root@linuxbeatswindows:/home/shoutcast# su – shoutcast

shoutcast@linuxbeatswindows:~$ tar zxvf sc_serv_1.9.8_Linux.tar.gz

Proceed to extract the other package.

shoutcast@linuxbeatswindows:~$ tar zxvf sc_trans_posix_040.tgz

Edit the Configuration files

There are two configuration files to be edited:

sc_serv.conf and sc_trans.conf

Firstly, let’s configure the sc_serv.conf file.

The parameters that are required to change are as follow:

shoutcast@linuxbeatswindows:~$ grep -v “^#” sc_serv.conf|grep -v “^;”

MaxUser=32

Password=yourpassword

PortBase=8000

LogFile=sc_serv.log

RealTime=1

ScreenLog=1

ShowLastSongs=10

W3CEnable=Yes

W3CLog=sc_w3c.log

SrcIP=ANY

DestIP=ANY

Yport=80

NameLookups=0

AdminPassword=yourpassword

AutoDumpUsers=0

AutoDumpSourceTime=30

PublicServer=default

AllowRelay=Yes

AllowPublicRelay=Yes

MetaInterval=32768

In my case, I just have to edit the ones in bold.

Next, let’s configure the other configuration file, sc_trans.conf. In my case the location of the file is at /home/shoutcast/sc_trans_040.

SHOUTcast Trans introduction

SHOUTcast Trans stands for SHOUTcast Trans(coder), as it is able to transcode mp3’s to lower or higher bit rates. SHOUTcast Trans works by streaming mp3’s from a play list specified in the configuration file.

$ grep -v “^#” sc_trans.conf|grep -v “^;”

PlaylistFile=/home/shoutcast/sc_trans_040/playlist.lst

ServerIP=radiohits.crabdance.com

ServerPort=8000

Password=yourpassword

StreamTitle=My Cool Radio Station

StreamURL=http://radiohits.crabdance.com

Genre=genres go here

LogFile=sc_trans.log

Shuffle=1

Bitrate=80000

SampleRate=44100

Channels=1

Quality=1

CrossfadeMode=1

CrossfadeLength=8000

UseID3=0

Public=1

AIM=AIMHandle

ICQ=

IRC=shoutcast

In my case, I had to edit the ones in bold. The things to take note here is the playlist

Setting up the playlist

Below is the command format of to produce the playlist.

find /path/to/mp3/directory -type f -name "*.mp3" > playlist_filename.lst

This setting tells SHOUTcast where to find its streaming media content from. This setting requires an existing file, so let’s go ahead and create a play list. I’ll create one real quick from my /home/mp3 directory referred to earlier.

# find /home/mp3 -type f -name "*.mp3" > /home/shoutcast/sc_trans_040/			playlist.lst

Notes:

The configuration I have is to allow the shoutcast server to be available on the Internet. Thus you have to setup dynamic DNS and also the web server,Apache. I will provide the how-to tutorials on setting up Apache web server and dynamic DNS in Annex A. I have also documented the tutorial on how to setup and configure virtual websites with dynamic DNS in my posting titled “Configuring Virtual Website with Dynamic DNS” in my blogs at isaraffee.wordpress.com.

Start Up sc_serv and sc_trans

Now let’s say you have completed setting up the virtual website and the dynamic DNS, it’s time to launch shoutcast server. There are two parts;firstly start the sc_serv and then followed by sc_trans_040. In my case I created two scripts to start up the programs. Here are the script listings.

The sc_serv listing:

root@linuxbeatswindows:~/script# more chkshoutshout

cd /home/shoutcast

./sc_serv sc_serv.conf

The sc_trans listing:

root@linuxbeatswindows:~/script# more chkshouttrans

cd /home/shoutcast/sc_trans_040

./sc_trans_linux sc_trans.conf

So start shoutcast by opening two terminals; in one terminal run the chkshoutshout script and in the other terminal run chkshouttrans.

After that launch your web browser and in my case, I go to radiohits.crabdance.com which I have already setup this virtual website on Apache and using Dynamic DNS to handle DNS queries. My website looks like the one below:

In my website, I have created a hyperlink. This is a work around as the default shoutcast website will show the shoutcast main page. Thus in your index.html, create a hyperlink like the one I have. In fact I have provided a template for a simple html page with hyperlink.

<HTML>

<HEAD>

</HEAD>

<H1>Welcome to My Radio Station !</H1>

<BR>

<A HREF=”http://radiohits.crabdance.com:8000/listen.pls“>Click here for LIVE Music from my room!</A>

</BODY>

</HTML>

Now once you click the hypelink, you will be prompted to open the downloaded file or save it. Simply click open and your media player will start to stream the songs and that’s it you have your own radio station broadcasted on the Internet. Invite your friends to listen to your shoutcast radio

movieplayer

Annex A

The following documentation guides you how to setup a virtual website using Apache webserver and also how to setup a dynamic DNS. The documentation is taken from my blogs posting titled “Configuring Virtual Website with Dynamic DNS” and in available online at isaraffee.wordpress.com.

This tutorial is basically made up of two main parts:

  • Adding Host in DDNS
  • Configuring Virtual Websites

Adding Host in DDNS

Firstly add your virtual website host in the DDNS site. I will add a host called linuxrocks in the minidns domain.

Make sure the www service is checked. You should also checked that the status of the newly created site is online. If it isn’t, activate it. You should also click on the Manual Update IP to update the IP address to the site. This completes the first part of the tutorial. Now let’s proceed to the second part of the tutorial, configuring the virtual websites on an Apache web server.

Configuring Virtual Websites

To start off, let’s create a simple website called linuxrocks.minidns.net.

Creating a Simple Web Page

To create a web page, follow these steps:

root@ubuntu:~# cd /var/www

root@ubuntu:/var/www#

root@ubuntu:/var/www# mkdir linuxrocks.minidns.net

root@ubuntu:/var/www# cd linuxrocks.minidns.net/

root@ubuntu:/var/www/linuxrocks.minidns.net# mkdir html/

root@ubuntu:/var/www/linuxrocks.minidns.net# cd html/

root@ubuntu:/var/www/linuxrocks.minidns.net/html# vi index.html

The main idea here is to create in index file for the site. Using vi editor, type

root@ubuntu:/var/www/linuxrocks.minidns.net/html# vi index.html

Welcome to linuxrocks.minidns.net

Save and quit. You can also add images and other stuff, but you can do all that after you have successfully created the site.

Preparing Apache for Virtual Sites

To prepare the web server to host virtual sites, follow these steps:

root@ubuntu:~# cd /etc/apache2/

Edit the apache2.conf and make its contents look like the one shown below. But before you do that it is always a good practice to make backup the original configuration file.

root@ubuntu:/etc/apache2# grep -v “^#” apache2.conf | more

ServerRoot “/etc/apache2″

LockFile /var/lock/apache2/accept.lock

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule mpm_prefork_module>

StartServers 5

MinSpareServers 5

MaxSpareServers 10

MaxClients 150

MaxRequestsPerChild 0

</IfModule>

<IfModule mpm_worker_module>

StartServers 2

MaxClients 150

MinSpareThreads 25

MaxSpareThreads 75

ThreadsPerChild 25

MaxRequestsPerChild 0

</IfModule>

User ${APACHE_RUN_USER}

Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess

<Files ~ “^\.ht”>

Order allow,deny

Deny from all

</Files>

DefaultType text/plain

HostnameLookups Off

ErrorLog /var/log/apache2/error.log

LogLevel warn

Include /etc/apache2/mods-enabled/*.load

Include /etc/apache2/mods-enabled/*.conf

Include /etc/apache2/httpd.conf

Include /etc/apache2/ports.conf

LogFormat “%v:%p %h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” v

host_combined

LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combine

d

LogFormat “%h %l %u %t \”%r\” %>s %b” common

LogFormat “%{Referer}i -> %U” referer

LogFormat “%{User-agent}i” agent

CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined

Include /etc/apache2/conf.d/

Include /etc/apache2/sites-enabled/

The next step to prepare the virtual site

Preparing the Virtual Site

To prepare the virtual website, follow these steps:

root@ubuntu:/etc/apache2# cd sites-available/

root@ubuntu:/etc/apache2/sites-available#

Create a file named after your website. In my case, it looks like this:

root@ubuntu:/etc/apache2/sites-available# vi linuxrocks.minidns.net

Its contents are as follow:

root@ubuntu:/etc/apache2/sites-available# more linuxrocks.minidns.net

<VirtualHost *:80>

#<VirtualHost 172.16.0.2:80>

ServerName linuxrocks.minidns.net

ServerAdmin webmaster@localhost

ServerAlias http://www.linuxrocks.minidns.net

DocumentRoot /var/www/linuxrocks.minidns.net/html

#DocumentRoot /var/www

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,

# alert, emerg.

LogLevel warn

CustomLog /var/log/apache2/access.log combined

</VirtualHost>

The important directive which needs to be mentioned here is the DocumentRoot (in bold). Make sure it has been created. You can also create error and access logs. But I want to make it simple. I ever did make typo errors and other mistakes like specifying an error log that was not created earlier, and it make Apache server failed to start. A very worrying experience but after reading the apache logs, it indicate that Apache could not find the error log that I tried to create. It took me sometime before I decided to totally delete that virtual site files. Eventually Apache web server started and things resume normally. What a relief!

Next, run the following command to enabled the site.

root@ubuntu:/etc/apache2/sites-available# a2ensite linuxrocks.minidns.net

You will need to reload apache:

#/etc/init.d/apache2 reload

This will create a link file as shown below:

root@ubuntu:/etc/apache2# cd sites-enabled/

root@ubuntu:/etc/apache2/sites-enabled# ll linuxrocks.minidns.net

lrwxrwxrwx 1 root root 41 2010-10-07 01:04 linuxrocks.minidns.net -> ../sites-available/linuxrocks.minidns.net

With that your newly virtual website should be available to the public. Simply launch a web browser and in my case, I type:

linuxrocks.minidns.net on the web browser address field

Advertisements
This entry was posted in apache, audio, media server, radio, shoutcast, sound, web server. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s