My ongoing experiences with Ubuntu, and later Mythbuntu, as a media center with MythTV. I'm also using the system for a virtual machine server, a mediawiki server and a general all around home infrastructure base.

Saturday, February 14, 2009

Multumedia volume keys not working...

Ever since I messed around with sound to get Skype and my USB headset working, my multimedia keys on the front of my laptop hadn't been working. The on-screen graphic would appear but nothing I did actually effected playback volume, basically exactly as this page described it:
If after assigning as described above, your VolumeUp/VolumeDown/Mute keys seem to work (i.e. you see a popup window with a slider in the middle of the screen that reacts on those key presses), but the playback volume actually remains unchanged, you may also have to setup what mixer tracks (channels) these keys should be bound to. Refer to this section below.
So, following the advice in the section referred to I opened System/Preferences/Sound and on the Device Tab I found the selectino for Default Mixer Tracks. It was set to "Logitech USB Headset (Alsa mixer)", I changed it to "Capture: ALSA PCM on front:0 (Intel ICH6) via DMA (PluseAudio Mix..." and now all works well.

Saturday, February 7, 2009

Installing Apache and PHP on my Ubuntu laptop and configuring a virtual host

I wanted to do some web development, so here's the process I used to install apache w/php and configure a virtual host on my Ubuntu laptop.

First, I followed these old directions as a starting point for installing Apache and php. But I found that the extra repositories were already added, Apache was already installed and after installing php5, libapach2-mod-php5 was already install, so all I really had to was:

# apt-get install php5
I test php functionality by creating a quick test file:
# vi /var/www/test.php
# cat /var/www/test.php
And pointing my browser at http://localhost/test.php and seeing "Hello World".

On thing I noticed is that I was getting the following error when restarting:
# apache2ctl restart
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
I fixed this by adding a ServerName directive to the Apache configuration (I actually don't think it matters what name you give):
# vi /etc/apache2/apache2.conf
# grep ServerName /etc/apache2/apache2.conf
ServerName localhost
Now, to install the virtual host so that I can test using code in my home directory. There are a number of sites out there if you google "apache vhost" and I didn't find any particularly good, so here is what I did.

For the sake of these directions, I'm going to use the name and I'm going to put the name into /etc/hosts. This will allow me to see things exactly as they will appear on the live web site.

First I edit /etc/hosts and add an entry for the vhost:
# vi /etc/hosts
# tail -1 /etc/hosts
Now it's time to edit the apache configuration:

# vi /etc/apache2/sites-available/myvhost.conf
# cat /etc/apache2/sites-available/myvhost.conf

DocumentRoot "/path/to/vhost/directory"

<Directory /path/to/vhost/directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Depending on what you need to do, you may not need the block. I have some local php configuration, so I did.

Now enable the vhost:

# a2ensite myvhost.conf
Enabling site myvhost.conf.
Run '/etc/init.d/apache2 reload' to activate new configuration!# apache2ctl restart
One last snag, probably particular to how I handled my php, but I had the following .htaccess file in my vhost root:
AddHandler php-html .html
Action php-html /php/process.php
Which caused the following error whenever I tried to access the directory:
Invalid command 'Action', perhaps misspelled or defined by a module not included in the server configuration
To fix this, I enabled the actions module:
# a2enmod actions
Enabling module actions.
Run '/etc/init.d/apache2 restart' to activate new configuration!
Now, just restart Apache:
# apache2ctl restart
And point my browser at and everything worked.

Update 2/21/09: If you want to be able to run 'php' from the command-line, you should also install the php5-cli package (kudos):

# apt-get install php5-cli

Sunday, February 1, 2009

apt-cacher report not updating

Update Mar 13, 2009: I've now fixed

I noticed this morning the amounts of hits and data transferred in my apt-cacher report are not updating. See report below, the date has changed but the values in the 'cache efficiency' table have not since my original install. Something is broken some where, either I'm not using the cache or it's not reporting correctly.

Don't have time at this moment to investigate, but will update this post when I do...

Updated: I started by killing apt-cacher to verify the clients were using it...
# /etc/init.d/apt-cacher stop
Stopping Apt-Cacher: apt-cacher.
And, yes, this caused 'apt-get update' on my client to return all sorts of 'Count not connect...' errors, so I know my previous configuration was working:
# cat /etc/apt/apt.conf.d/90local-proxy
Acquire::http::Proxy "http://proxy-host:3142";

So I restarted apt-cacher ("/etc/init.d/apt-cacher start") and looked at the server side harder.

First, I checked to see if there was anything in the cache, and there was lots of stuff including new packages as of today, including wine, which is only on one of my clients and not the server, which would seem to indicate things are working as I should expect:
# grep cache_dir /etc/apt-cacher/apt-cacher.conf
# cache_dir is used to set the location of the local cache. This can

# du -s /var/cache/apt-cacher
1966256 /var/cache/apt-cacher
# ls -lt /var/cache/apt-cacher/packages | head -3
total 1947272
-rw-r--r-- 2 www-data www-data 0 2009-02-01 09:05 wine.budgetdedicated.com_apt_dists_intrepid_main_binary-i386_Packages.gz
-rw-r--r-- 2 www-data www-data 0 2009-02-01 09:03 wine.budgetdedicated.com_apt_dists_intrepid_Release

Ok, the issue would seem to be reporting. I checked relevant options in apt-cacher.conf and didn't see any issue.

# grep generate_reports /etc/apt-cacher/apt-cacher.conf
So I started looking a little harder at the apt-cacher logs and the /usr/share/apt-cacher/ script that generates the reports, and noticed a problem. Here's what a line in my logfile looks like:

# head -1 /var/log/apt-cacher/access.log
Sun Feb 1 08:22:01 2009|15927||MISS||ppa.launchpad.net_network-manager_ubuntu_dists_intrepid_Release.gpg

And here is the section of the apt-cacher/ script that parses it:

$req_date = $line[0];
# $req_ip = $line[1];
$req_result = $line[2];
$req_bytes = 0;
$req_bytes = $line[3] if $line[3] =~ /^[0-9]+$/;
# $req_object = $line[4];

If you don't understand PERl, basically there is a mismatch. The script is looking for the result (HIT or MISS) in the third column (column 2 starting from 0), but the IP address is there. It expects the number of bytes in column 4, but they are in column 2. So this would seem to be the problem, but why this discrepancy?

Update: See a later post for the fix.

Current apt-cacher report output (made narrow to fit into blow):


Item Value
Report generated 2009-02-01 09:02:18
Administrator root@localhost
First request Thu Oct 30 22:01:39 2008
Last request Sun Feb 1 08:22:05 2009
Total requests 27678
Total traffic 1980.17 MB

cache efficiency

Cache hitsCache missesTotal
Requests 2569 (9.28%)25109 (90.71%)27678
Transfers 955.718 MB (48.26%)1024.452 MB (51.73%)1980.17 MB