FreeBSD
Miscellaneous FreeBSD bits
There are a few other things that are worth configuring but don't really fall into any of the previous sections so I'll just lump them in together here.
ntpdate
The station module requires that the clock on the server be reasonably accurate. FreeBSD can use the Network Time Protocol (NTP) to synchronize your server's clock to a time server. To enable the ntpdate script, you'll need to add the following lines to your /etc/rc.conf file:
ntpdate_enable="YES"
ntpdate_flags="north-america.pool.ntp.org"Next you'll want to add a cron job to the root user's crontab file:
$ crontab -eThe following entry will synchronize the clock every morning:
# Every morning at 4am update the clock.
0 4 * * * /etc/rc.d/ntpdate start > /dev/nullEnabling PHP Modules
Phlickr uses two several of PHP5's extensions, CURL and SimpleXML. In some cases these two extensions may not be enabled by default.
The first step is verify that the modules are not already being loaded. You view a list of the modules using the following command:
Conclusion
Hopefully these instructions will be of use to people. My goal was to de-mystify the process putting a radio station on the web as well as providing specific reference for those who building such a site with FreeBSD.
If you have questions, comments, or would like to arrange consulting feel free to contact me.
Icecast setup
Enable the Icecast daemon by adding the following line to your /etc/rc.conf file:
icecast_enable="YES"You'll need to make a copy the default Icecast config file:
$ cd /usr/local/etc/
$ cp icecast.xml.sample icecast.xmlNow you'll need to edit the icecast.xml file. Notable thing to change:
<source-password>- obviously the default hackme isn't a good choice<relay-password>- ditto<admin-password>- double ditto
Setup the Drupal station module
First you'll want to install these packages:
- archivers/unzip - you need this to unzip the getID3 library
Now we'll check out the necessary Drupal modules using CVS. CVS makes it very easy to keep up-to-date on changes made to the modules. It's as simple as running cvs up -dP.
Install audio packages
You'll want to use pkg_install the following:
- audio/darkice - Encodes audio from the sound card and sends it to the Icecast server.
- audio/icecast2 - Serves up the web stream.
- audio/streamripper - Saves the web stream to files. We use this to build the program archive.
- www/lynx - Terminal web browser, this is optional but it helps verify that Icecast is setup correctly.
The following pages will walk you through the configuration of these packages.
Setup Apache and MySQL
To run the website, we'll install a database, webserver and scripting language. You'll need to install the following ports and their dependencies:
- databases/mysql51-server - MySQL server
- www/apache22 - Webserver
- lang/php5 - PHP
Setup Drupal 5
The station's website will be build using Drupal an extremely powerful, open source content managment system written in PHP.
Drupal uses some PHP functions that require the installation of additional ports. You'll need:
- devel/php5-pcre - Perl regular expressions.
- textproc/php5-xml - XML parsing.
- databases/php5-mysqli - MySQL support for PHP.
- www/php5-session - Session support.
- graphics/php5-gd - Image handing. Optional, some modules need it.
- converters/php5-mbstring - Unicode support. Optional, but Drupal prefers that it be installed.
Recording from the soundcard
These are the steps to configure FreeBSD to record audio from the sound card. This assumes you've got a supported sound card. This is an easy process but it took me quite a bit of trial and error to work out the details.
Darkice setup
Darkice handles the nitty gritty of reading audio from the sound card and feeding it to Icecast. You can create multiple streams with different bit rate from a single input. The configuration detailed here creates two streams, one high bandwidth users and one for low bandwidth users.
HOWTO: A FreeBSD radio station web server
This HOWTO walks you through the process of building a FreeBSD server to put a radio station on the internet. When you're finished you'll have a:
- Apache2 web server
- MySQL 5 database server
- Icecast2 MP3 webstream
- Drupal based website with:
- Program schedule
- MP3 Archive of broadcasts
This is the setup pioneered for use by KPSU, a college radio station in Portland Oregon, to stream and archive our broadcasts on the internet. I've released the code as the Drupal Audio and Station modules. You can find a list of some of the websites using the Station module.
All the software is free and open source. The only thing you've got to pay for is your time and hosting. While the details are FreeBSD specific, the general setup can be used for any UNIX like OS.
First, setup FreeBSD, use the handbook for that. Sorry to be so vague on details but that part of the setup is going to vary greatly depending on your hardware. The handbook will do a better job of explaining it than I could hope to do.
Once you've got a running server, start making your way through the following pages:
Things I never remember when reinstalling FreeBSD
I totally whacked the KPSU archive machine today. It's one of those standard stories of being stupid and then being in a rush to compound it. So now I'm building a backup machine to stand in while try to rebuild the archive.
Learning from my mistakes:
- sysinstall is a handy pistol. Use it to shoot yourself in the foot.
- dd is your best friend, provided you've got extra disk space. You just make an image of drive you've sort of fucked up and then you can restore back to that image when your troubleshooting go wrong.







