Friday, January 23, 2009

Installing SwissCenter on Ubuntu Server

I got SwissCenter up and running on my fit-PC Slim, which is now running Ubuntu 8.10 Server.

At first I was working off the official SwissCenter Linux install documentation which is for SuSE 9.3. Later on I found this cheatsheet for installing SwissCenter on Ubuntu which is a bit out of date now, but still very useful.

Install apache2 and mysql

I had these installed already, done in the standard way as in the Ubuntu Server Guide, which is to say
$ sudo apt-get install apache2
$ sudo apt-get install mysql-server
Actually, I had the default mysql instance disabled, so re-enable it now and maybe try converging to a single mysql instance later.
$ cd /etc/rc2.d
$ sudo mv K81mysql S19mysql
$ sudo /etc/init.d/mysql start
Install PHP
$ sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-gd
Install SwissCenter
$ wget http://www.swisscenter.co.uk/downloads/swisscenter.zip
$ sudo mkdir -p /srv/www/swisscenter
$ cd /srv/www/swisscenter/
$ sudo unzip ~/swisscenter.zip
$ sudo chown -R www-data:www-data .
(Using www-data which is the standard apache user/group in Debian-based distributions, rather than wwwrun as specified in the SwissCenter document.)

Enable the site in Apache

Slightly different from the document here... I appended the following to /etc/apache2/sites-available/default
Listen 8080
NameVirtualHost --myhostname--
<virtualhost>
DocumentRoot "/srv/www/swisscenter"
<directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</directory>
<ifmodule>
DirectoryIndex index.html index.php
</ifmodule>
</VirtualHost>
Then restarted apache.

Checking and configuring SwissCenter

Point web browser to the SwissCenter Configuration page at http://<servername>:8080/config. On first attempt, the page showed:
Warning: dl() [function.dl]: Dynamically loaded extensions aren't enabled in /srv/www/swisscenter/base/image.php on line 50

Fatal error: Call to undefined function imagecreatetruecolor() in /srv/www/swisscenter/base/image.php on line 251
After a bit of searching, I found I needed to include php5-gd (included in the install command above. I didn't have it originally), so
$ sudo apt-get install php5-gd
$ sudo /etc/init.d/apache2 restart
Better this time. But the page still shows some errors under Installation Checks.
Unable to locate a TrueType font. The "Now Playing" screen will be missing track information.
Google turned up this, which helped me to find Advanced Options / Miscellaneous in the SwissCenter configuration pages where you can set the path to a TT font. I entered /usr/share/fonts/truetype/freefont/FreeSans.ttf.

That left a warning that database is not created yet. You create it from the SwissCenter Create Database page. On first attempt, I got
Unable to create database - Is your MySQL "Root" password correct?
Umm... Looks like I changed the default mysql root password when I installed mysql. I've forgotten it now. So I had to reset the root password. Now I can create the database successfully.

Back on the main Configuration page,
Unable to write to the SwissCenter playlists directory (playlists)
Under Media Management / Playlists, you enter a full path to a dir (which must be writeable by www-data user), i.e. created something like
$ sudo -u www-data mkdir <some_dir>
After all that, SwissCenter is up and ready to load some content. I pointed it to my photos and music directories for a start.

Accessing SwissCenter from the Popcorn Hour

The simplest way for a start is to add the SwissCenter URL to the Web Services page in the Popcorn Hour, i.e. create an entry pointing to http://servername:8080.

But you can run an additional service on the server to broadcast the SwissCenter's UPnP interface. With that running, SwissCenter shows up automatically in the Popcorn Hour's Media Sources page.

There's a nice custom broadcast script and a Debian init script to start and stop this broadcast service automatically. I modified the init.d script slightly to make it run in the background:
$ diff -upN broadcast.orig broadcast
--- broadcast.orig 2008-09-11 17:02:03.000000000 +0100
+++ broadcast 2009-01-11 02:00:52.011883945 +0000
@@ -46,7 +46,7 @@ do_start()
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
@@ -95,7 +95,7 @@ do_reload() {

case "$1" in
start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@@ -103,7 +103,7 @@ case "$1" in
esac
;;
stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

And that's about it.

3 comments:

  1. Just so you know, I updated the broadcast script to work with the newest PCH firmware (as they changed the server response string in the newest firmware). The details are in the link you mentioned above...

    ReplyDelete
  2. Cool. Thanks for the update. Much appreciated.

    ReplyDelete
  3. Thanks, I had to install php-gettext to get it running, but now it works.

    ReplyDelete