Category Archives: linux

Temporarily use a blog page as your front page

I wanted to temporarily redirect people who browse to www.keynote.org to the page www.keynote.org/donate.  Since this is a WordPress site, I should have been able to easily do this by logging into the dashboard and going to Settings – Reading and changing the static front page to the Donate page.  For some reason, the Donate page wasn’t rendering properly, even though the page looked fine when it wasn’t set as the front page.

Rather than take the time to figure out what is going on in the WordPress processing, I added the following line to the .htaccess file after “RewriteBase /”:

RewriteRule ^$ http://www.keynote.org/donate [L]

This matches any browser requests that don’t have anything after the hostname and redirects them to /donate. It seems to be working well so far.

Communicate your message through a custom 404 error page

Mars Hill 404

I love the idea of using a custom  error page to communicate the gospel — I wish I were that creative!  Above is the 404 page that you used to get from Mars Hill Church.

Think about ways that you can use your 404 page to educate, encourage, or entertain.  Hopefully your site is organized well enough that people won’t see the page often, but they will eventually — it might as well be a positive experience!

Depending on how you’re hosting your web site, there are different ways to customize your error pages.  If you’re using WordPress, your theme might have a custom 404 page template as described here.  If you’ve coded your site manually, your web host might have a control panel to edit error pages, or you can point to custom error pages via your .htaccess file.  The web host 1and1 shows how to use the .htaccess file here.

1and1 upload_max_filesize problem

This is one of those frustrating stories for a tech, where you bang your head against a problem for a few hours, finally fix it, then try to break it again to document it and it doesn’t behave the way you expect.  But it’s still working, so maybe it will still help someone else…

I was trying to upload a 4 MB photo to my WordPress 3.4.2 site hosted at 1&1, and the uploader told me that it was too big — that the maximum upload file size was set to 2 MB in php.ini.  It doesn’t appear that 1&1 gives me access to the main php.ini, so I tried to add one to the root folder and/or the wp-admin folder of my WordPress installation.  Neither seemed to work, but I eventually figured out that I needed the file in the wp-admin folder and I needed to log out and back into the WordPress dashboard.  Here’s the simple php.ini that I added to the wp-admin folder:

upload_max_filesize = 10M
post_max_size = 10M

What was extra frustrating was what happened when I removed the php.ini to document this: instead of going back to 2 MB, the maximum upload size went to 8 MB.  That’s bigger than I needed, and if it had started that way I wouldn’t have had to go through all of this.  I can’t explain it!

Raspberry Pi White Noise Generator

It’s helpful to have a white (or brown) noise machine outside our director’s office, since his office is next to the lunch room and it helps to make his conversations more private.  But all of the machines that I saw on the market are sleep-oriented, and expect that you want them to turn off after a certain amount of time.

We started with a laptop, powered speakers, and the SimplyNoise.com web site (we like the “Brown Noise” sound there).  We could use the mute button on the laptop or the power button on the speakers to turn the sound on and off.  But that’s a waste of a laptop if the machine is good for anything else, and problem-prone if the laptop isn’t good for anything else.

So I decided that this would be a good first project for the Raspberry Pi. I found that mplayer will loop an audio file forever if you use the “-loop 0” switch. It does go silent for a split second when it’s looping, so you’ll want an audio file at least 15 or 20 minutes long to minimize the number of times it sounds like it’s stuttering.

There are plenty of tutorials out there about getting started with the Pi.  After that, it’s as simple as:

  1. Load up an mp3 or wav file with 15 or 20 minutes (or more) of noise.
  2. sudo apt-get install mplayer
  3. create /etc/init.d/whitenoise.sh (included below)
  4. add it to system startup with “sudo update-rc.d whitenoise.sh defaults”

This could also be used as a Music on Hold player for older phone systems.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          whitenoise
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: whitenoise
# Description:       plays whitenoise file.
### END INIT INFO
/usr/bin/mplayer -quiet -loop 0 /home/pi/whitenoise.mp3 < /dev/null &
exit 0

Inexpensive, commercial-free live streams with Wowza and EC2

After streaming several live events with Livestream and Ustream, the advertisements that they embed have become increasingly intrusive.  Ustream now inserts video ads into the middle of a webcast, which will result viewers missing parts of the show.

Someone suggested running Wowza Media Server on an Amazon EC2 instance.  For occasional webcasts, combining the $5/day Wowza license with $0.26 per hour for EC2 and the free Adobe Flash Media Live Encoder (FMLE), and you have a very affordable and powerful system.  And it’s not too hard to piece together.  Here’s what you’ll need:

  1. An audio/video source, obviously.  This can be as simple as a webcam.  We already had an s-video switcher and a sound board at the venue, so we used the switcher to choose between a camera, DVD player, and computer (for graphics).  We combined the s-video and aux outs from the sound board with a Canopus ADVC-110 analog to digital converter.  That connected to the broadcasting laptop via firewire.
  2. To send the stream to the media server, you need some software.  Adobe FMLE works well and is free, and it’s what we used.  It doesn’t let you do titles or switch between video and graphics, but we did some of that with the s-video switcher.  If you have $500, you can invest in Wirecast, which I’ve heard very good things about.  I tried XSplit, but it didn’t like the Canopus device.
  3. Sign up for EC2 from Amazon Web Services (AWS) and spin up a Wowza instance.  Amazon offers preconfigured Wowza servers that will do everything you need for simple webcasts.  There are good instructions here.  I did notice that I didn’t need to create the security group mentioned in the instructions — Amazon created one automatically for the Wowza server.
  4. Start streaming from FMLE or your other streaming software to the Wowza server.
  5. Embed the stream on your web site with a player like JW Player (free for noncommercial use). If you want viewers to be able to use iOS devices, make sure that you configure your stream according to the tips in this thread.  Here is the code that we used on our web site to enable regular browsers in addition to iOS devices:
Loading the player ...

If you want the Wowza server to automatically record the stream, it’s not difficult to set up a new stream type called “live-record” on the server.  Just point your streaming software to that, and you’ll have a file in the content directory of the server when you finish the webcast.  Look here to get started.

I hope this helps someone get started with commercial-free live streaming!

Getting wireless working on Dell D600 with Ubuntu

I was pleased at how easily Ubuntu 11.4 installed on my old Dell Latitude D600, but the wireless didn’t work immediately.

Thankfully, I just had to search for “firmware-b43-installer” in the Ubuntu Software Center, and that did it!  By the way, I had to reinstall it after letting the software upgrade tool upgrade me to 11.10.  The upgrade generated a bunch of errors, but it appears that they were all related to the wireless.

Error hosting facebook app on 1and1

facebook error

I was creating a facebook app and trying to host the canvas URL on my 1and1 hosting account.  Even though I could browse directly to the index.html and it would render fine, I would get an error when trying to browse to it via apps.facebook.com.

“Method Not Allowed.  The requested method POST is not allowed for the URL …”

Although I have not encountered this problem on other web hosts, it appears that 1and1’s web server is set up a little differently.  When you browse to the canvas page via apps.facebook.com, facebook sends some POST variables to your site.  1and1 doesn’t allow an html file to render when POST variables are sent.

A simple workaround is to rename your index.html to index.php. That makes 1and1 think that the POST variables are expected.

WordPress Permalinks issue with Bluehost

403 errorIf you’ve tried running WordPress on Bluehost, you may have run into this:  you change your Permalink Settings, and the site no longer works.  You get “403 Permission Denied”.

The fix is pretty simple.  Just edit the .htaccess file in the blog’s root directory and add the line Options +FollowSymlinks. I put it after <IfModule mod_rewrite.c> because that was suggested by the article that I found on the interwebs.

I don’t know why I’ve only had to do this with Bluehost, but their tech support told me that they don’t have any plans to fix whatever the underlying issue is.

Moving a Joomla site with Akeeba Backup (JoomlaPack)

I was trying to use Akeeba Backup (formerly “JoomlaPack”) to move a Joomla site from a temporary location under my personal site to its own hosting account.  The site packed up fine, but I got the error “Could not open logs/index.html for writing” when unpacking with kickstart.php.

A little research revealed that you sometimes get this error when unpacking to a hosting account’s root folder.  You can get past this by unpacking to a subdirectory and then moving the files to the root.  It looks to me like my host, 1and1, wasn’t allowing the kickstart scripts to write to the logs folder.  I couldn’t figure out how to fix the permissions, so I used the subdirectory workaround.  After unpacking everything to a subfolder and then moving it to the root, I just needed to change two paths in configuration.php and the site was working.  I never was able to move logs/index.html to the main logs folder, but the site is working fine without it.

I did need to follow one important tip in the Akeeba Backup manual and force “binary mode” when transferring the site’s .jpa archive file down from the original host and up to the new site.