Enabling UserDir on only one Apache VirtualHost

Let’s say you have a web server running apache and you have a bunch of virtual hosts for a bunch of domains. You want to enable UserDir so that example.com/~user URLs automatically map to (by default) the public_html directory in each user’s home directory. Apache already includes a userdir module, so you go and enable it. But, oops, by default it enables it on all your hosts, not just one. You want it enabled on just one, not all of them. So you go and google and there are a bunch of complicated solutions to this that seem way too much like overkill. Fortunately there is a much simpler solution:

First, go to your apache configuration directory, for example on Debian:

cd /etc/apache2

Second, enable the userdir module:

sudo a2enmod userdir

Third, delete the enabled userdir configuration file:

sudo rm mods-enabled/userdir.conf

Fourth, edit the virtual host configuration file, e.g. sites-enabled/example.com.conf, that you want to use userdir on and add this line within the VirtualHost scope:

Include mods-available/userdir.conf

Fifth, reload apache, usually by running (if you use systemd):

sudo systemctl reload apache2

Really simple, right? An explanation of this is in order: Why did we enable it only to delete the configuration? Enabling a module actually does two things: First it adds a .conf file that tells apache the default configuration of the module. Second it adds a .load file that tells apache to load a dynamic library with the executable code that apache runs when the module is used.

By default, the .conf file applies globally, i.e. to all of the sites in use. This is great if you want all of your sites to do the same thing. It’s not so great if you want the module enabled only on one or a few sites. The effect of the above is to load the dynamic library so that apache can use it, but not to add the global configuration. The “Include” in the virtual host configuration file will enable the configuration for the module for that virtual host only.

If you need to further tweak things (enable or disable specific usernames, the path, etc.) then instead of using “Include” you can copy the contents of mods-available/userdir.conf into your virtual host configuration file and customize as needed.

In principle, the same procedure should work for other modules you want to use only on specific virtual hosts.

Character set error

Because this blog was set up a long time ago, the character set settings in the database were not consistent. As a result of this and a recent WordPress upgrade, all Chinese characters on the blog were corrupted. I’ve fixed everything in the user interface, but any Chinese text in posts has been corrupted. Unfortunately due to an error in backups, no fixable backup copy was available.

The mirror at LiveJournal was unaffected by this error.

How to sideload VLC on Fire TV

Many of you may be familiar with the VLC video player from its Windows version, but they also have a version for Android which also works on Fire TV devices. VLC is a great addition to Fire TV for moderate to advanced users, as it allows you to stream videos from internal storage, from Windows Shares over your local network, or from standard video streaming services. I use it mostly to access videos from Windows/Samba shares on my local network. Unlike other solutions like Plex which require additional software to be installed and index your content, VLC can play a video straight over the network share. Just share a folder to the network, and you can play anything in there without any complications.

Why sideload though? Amazon Appstore has the VLC for Fire app already there. You can just click to install and you’re ready to go. Unfortunately the version in the appstore is old, flaky, and rarely updated. At this writing, the Amazon Appstore has version 2.1.11 of VLC, while the latest available is 3.0.5. With the version from the appstore, I was having frequent problems with hangs, crashes, buffering during playback, and problems playing some files. After sideloading the latest version, all of these problems disappeared.

Sideloading is a bit complex, but it’s not too hard. Even if you’ve never sideloaded before, you can go through this step by step and be running the latest VLC in no time.

There are a couple of things to prepare your Fire TV to sideload VLC:

First, you need to turn on the ability to install sideloaded apps. This may sound a bit scary, but all this does is let you install things that didn’t come directly from Amazon. As long as you are careful to install only apps from reputable sources, you should be fine. On your Fire TV, go to Settings at the top right of the home screen, then click on “Device”, then “Developer options”, then look if it says ON or OFF under “Apps from Unknown Sources”. If it says “ON”, you’re already set. If not, press it and then select “Turn On”.

Second, you’ll need to uninstall VLC if it you’ve already installed it from the appstore. If you don’t do this, it will try to upgrade it during sideloading but fail because the application source was different, so you have to uninstall what you have first. Go to “Settings”, then “Applications”, then “Manage Installed Applications”. Scroll down to VLC and if it is there, click on it, then click on “Uninstall”. When it is done, repeat these steps again to confirm that VLC is no longer listed.

Next you have to get the APK which is the application package installer loaded on your Fire TV. If you’ve ever done sideloading on a phone or tablet you probably just hooked it up via USB to your computer and dragged and dropped the file to the device’s storage. You can’t really do things that easily with Fire TV. Fortunately there’s an app for that. Go to the home screen on your Fire TV device. If you have an Alexa enabled Fire TV device, just hold down the microphone button and say “Downloader” or, go to the main screen’s search feature in the upper left and type in “Downloader”. You should see a big orange button called “Downloader”. Click on that and install it.

Now that “Downloader” is installed, go to the home screen and click on and run “Downloader”. If it isn’t on the apps list on the main screen you may need to search for it in your apps list. It will then prompt you to enter the source you want to download and install from. For VLC, you want to enter “get.videolan.org” and then press the “Go” button. This is the official VLC website. Be careful not to get it from any other source. Next scroll down and click on “vlc-android”. On the next screen select the version you want to install. You’ll usually want the latest version.

On the next screen you’ll see a list of APKs for various platforms. Which one should you choose for Fire TV? If you have a 4K Fire TV device, then you probably want the ARMv8.apk package. If you have a 1080p Fire TV device, you want ARMv7.apk. Click on the appropriate version and a few seconds later the download should start. It may take a few seconds or minutes to download depending on your network speed. Once it does it should prompt you to install. Scroll down and click “Install” and a few seconds later it will say “App installed” if it was successful.

If for some reason it says “App not installed” then something went wrong. If you were trying to install the ARMv8.apk package, go back and try the ARMv7.apk package instead. Otherwise go back to the start of this guide and make sure that unknown sources is turned on, and any existing VLC package is uninstalled.

Once it installs successfully you can go back to the home screen and look for it in your list of apps or search your apps for VLC and run it. Then scroll down to the “Other” menu and make sure “About” shows the correct version number. That wasn’t so hard, was it?

One thing to keep in mind is that since you manually installed VLC, it will not be automatically updated by the appstore. You should periodically upgrade to the latest available version if you want to keep up to date. If you upgrade using the same source then you can install it without needing to uninstall the current version.

VPS Migration

Tonight I migrated my VPS from vpslink which I no longer recommend to GeekStorage. They both run Debian on OpenVZ/Virtuozzo, so I figured it wouldn’t be hard to migrate over.

I didn’t really find much about migration on the user side. Most of the migration pages were about how to migrate containers from the host server’s perspective. I did manage to cobble together enough clues to figure out what to do.

Basically to summarize the essential points, you can just copy everything from the old server to the new, clobbering whatever is there, EXCEPT for the following:

/aquota.group
/aquota.user
/etc/fstab
/etc/hostname
/etc/hosts
/etc/resolv.conf
/etc/network/interfaces
/etc/network/interfaces.template
/dev
/proc
/sys

In more detail:

On vpslink I have Debian on OpenVZ. So when I signed up the GeekStorage, I requested Debian on Virtuozzo. OpenVZ is the open-source variety of Virtuozzo, so they are close enough.

When GeekStorage said the VPS was ready, I logged in and used rsync to copy everything from the old server to /backup/old. That took a few hours. Then on the old server, I shutdown all the services (sendmail, apache, mysql, tinymuck, etc.) and then ran rsync again. That updated everything that changed while the first rsync was running, and was fairly quick.

Once that was done, I put the server in repair mode. This creates a temporary container with the real container’s contents mounted under /repair. I logged into the repair mode serve. First I moved everything in /repair except aquota.*, backup, dev, proc and sys to /repair/backup/orig. This moves the new VPS’ original OS files out of the way.

Then I moved everything in /repair/backup/old except aquota.*, dev, proc and sys to /repair. That moves the old VPS’ OS files to the new VPS’ root directory. Then I copied the etc files (see above) from /repair/backup/orig/etc to /repair/etc.

Caveats: Remember that there are probably hidden dotfiles in the old and new root dirs you need to move too. Also remember to always work in /repair when in repair mode. It’s easy to forget and start twiddling in /etc instead of /repair/etc. That disappears as soon as repair mode is finished.

Then I took the server out of repair mode, which boots into the VPS container again. And miraculously, it booted up just fine with everything looking just like it was on the old VPS. I had to twiddle a couple of other files with hardcoded IPs, but the OS came up just fine. I also had to update a bunch of things in DNS and wait for DNS caching to time out.

Windows Update Fail

For several days now my desktop system has been trying and failing to install a windows update for “Microsoft UAA Bus Driver for High Definition Audio” over and over again. The update was from 2004 so it is unclear why this was suddenly something it is trying to install now. I finally got whatever it was resolved:

– In Device Manager (Control Panel, System, Hardware, Device Manager) expand the “System devices” category

– For each “Microsoft UAA Bus Driver for High Definition Audio” device, right click and select “uninstall”

– It will ask you to reboot; do so.

– When it reboots it will reinstall the device and ask you to reboot again; do so.

– Now you should no longer see the update trying to install.

(It may try and fail to install the update again during the two reboots but just ignore that. It should be back to normal after the final reboot.)

Using Eset NOD32 Antivirus on English OS in Taiwan

One of the problems for users of English version OS in Taiwan is it is often difficult to get English versions of software as most items on the shelf are the Chinese version. A critical requirement on any computer is antivirus software.

I had previously used AVG (Commercial Version) on my main Desktop and Laptop systems, but it has been getting a bit bloaty and intrusive lately. (I still use and recommend the free version on less critical PCs.) Several months back I started looking at other AV solutions and two that came highly recommend were Kaspersky and Eset NOD32.

I had received a 90 day trial of Kaspersky with a hard drive I bought, so I gave that the first chance. Unfortunately while Kaspersky was fairly efficient, it was much more intrusive than AVG. When installing software it would almost always warn of the impending doom that could be caused by SETUP.EXE and verified that I was willing to risk death and destruction by running it.

It also frequently popped up confirmation dialogs when running programs for the first time, and generally was fairly generous about notifying me about all kinds of non-serious things. I don’t want my AV software to do that. I just want it to sit there quietly and quickly checking things and only telling me when it finds a real problem. So, Kaspersky was ruled out.

Then I downloaded a free 30 day trial of Eset NOD32 and for the whole trial period it did exactly what I wanted, quietly sitting in the background and only popping up when a real problem was found. (The first time this happened was late in the trial period when I started backing up my Gmail.) I managed to make it through the trial period without it annoying me with stupid stuff.

So now the problem… Only the Chinese version is sold in Taiwan. I did some searching and it seemed that it would be possible to switch to the English version, but nothing conclusive. Eventually I had to decide, so I rolled the dice and bought a copy. If you need to do the same thing, here is what you need to do:

  1. Buy a copy of the software. I bought it from PC-Home’s 24h Shopping. I bought the 3 Year License Home Version. (Click on NOD32 on the left if you want a different license.)
  2. When you get it, look at the back of the manual to find your license code. You will need to activate on the Eset’s Asia servers, not their US servers. If you can manage basic Chinese then you can register on Eset Taiwan or if you need English, go to Eset Singapore.
  3. After you register, click on the Download link and then select “Download Purchased Software / Home Users” and scroll to the bottom for the English 4.0 version. The “Download” link will download the software and the “Manual” link will download the manual. (That’s for the Singapore site. The Taiwan site is organized a bit different. Click on download then select the English download link.) You will need your username and password to download, which is emailed to you about 15 minutes after registering.
  4. Install the software.

Only one extra caveat. When I used the “Verify License Validity” option just after installing, it didn’t work. However, it was working fine by the next day. I’m not sure if it was something broken yesterday or if there is a delay during registration.

Setting Kindle Date and Time Without Wireless Networking

One drawback of using your Kindle 2 in an area without wireless connectivity is that the date on your Kindle will not be set correctly, but instead be set to sometime in 1970. (UNIX timestamps start from January 1, 1970 and Kindle’s software runs on Linux.) This is really not a very serious problem except that your bookmarks, notes and clippings files will have bogus timestamps.

Fortunately there is a hidden option to enable networking over USB connections. If this connection is enabled and properly set up, then one of the things it will do when connected is set the time. The time on mine was set to UTC (sometimes called GMT) time zone instead of Taipei time (UTC+0800), but at least it is only 8 hours off instead of 39+ years.

I learned how to set up USB networking on Kindle from Jesse Vincent’s blog post Tethering your Kindle 2 where he explains how to do this on MacOS. Since Windows systems are a bit different below is a shorthand version for Windows XP. If you get confused by anything, see Jesse’s original post for more detail. Vista procedure is probably a bit different.

  1. Get the driver here: http://www.davehylands.com/linux/gumstix/usbnet/linux.inf (If you run XP x64 or Vista 64-bit, you will need to modify the driver as documented here: http://docwiki.gumstix.org/index.php/Windows_XP_usbnet#Step_7.)
  2. Enable Internet Sharing on your Windows box. Open the “Network Connections” Control Panel, right click on your main network connection and select “Properties.” Select the “Advanced” tab and enable “Allow other network users to connect …”
  3. On your Kindle press “HOME”.
  4. Search: ;debugOn
  5. (Optional) Search “`help” to verify debug mode is on; you should get a list of available commands.
  6. Search: `usbNetwork
  7. Search: `usbQa
  8. Connect your Kindle to your computer’s USB port. You should see a network connection detected. When it asks to install a driver tell it to manually install, and point it to the directory you saved linux.inf to.
  9. The “Network Connections” Control Panel will now have a new network connection listed. Right click on it, select “Properties,” click on “Internet Protocol (TCP/IP)” at the bottom of the scroll box and press “Properties.” Enter the following: “IP address: 192.168.15.200” “Subnet mask: 255.255.255.0.”
  10. Shortly after connecting to the Internet you Kindle should update the time setting. You can confirm if it does so by searching: @time
  11. To get your Kindle back to normal USB mode, restart it: “HOME” “MENU” “Settings” “MENU” “Restart”

ssh logins for any user on QNAP TS-409

The QNAP NAS servers run a Linux OS and out of the box supports ssh logins as the “admin” user (basically root with a different name). But if you add a user and try to log in, it just closes the connection. If you look at /etc/ssh/sshd_config you’ll notice that there is a configuration line for “AllowUsers admin” which may lead you to believe that you just need to modify this line. Unfortunately the ssh server itself is also hard coded to allow admin logins only.

There are several guides for how to get around this restriction. The solution involves installing openssh either in addition to or as a replacement of the built in sshd. Many of these guides seemed overly complex to me, so I took several of them and came up with what I think is the simplest approach to replace the existing sshd with one that allows logins by all users.

This guide is known to work with the QNAP TS-409 running firmware 2.1.2 Build 1112T. It will probably work with other QNAP models, or other firmware versions, but no guarantees. This assumes you know how to ssh to your NAS as admin, you’ve created a new user and you already have ipkg installed and working. If you don’t have ipkg, see this http://forum.qnap.com/viewtopic.php?f=85&t=1085 and follow the “Sit Back” approach.

First install openssh:

ipkg update
ipkg install openssh

Now let’s swap out the stock server with the ipkg version:

mv /usr/sbin/sshd /usr/sbin/sshd-orig
cp /opt/sbin/sshd /usr/sbin/

Now on QNAP servers the filesystems are a bit strange because the OS is loaded from firmware onto a ramdisk. As a side effect of this, some system modifications will disappear upon reboot unless you follow special procedures to preserve them. This is true of the /etc/ssh/sshd_config file. We will need to move it to a location outside of the ramdisk.

cp /etc/ssh/sshd_config /mnt/HDA_ROOT/.config/ssh/

Next we need to edit the relocated sshd_config file (use your preferred editor if you don’t like vi):

vi /mnt/HDA_ROOT/.config/ssh/sshd_config

You have two choices when editing this file. Option one is to edit AllowUsers to add the usernames you want to be able to log in. Each username is separated by a space. Alternatively, you can comment out the AllowUsers line completely which will allow any user to log in.

Next copy it back to the normal location:

cp /mnt/HDA_ROOT/.config/ssh/sshd_config /etc/ssh

At this point you can test your configuration. BUT… you are NOT done yet. There’s one more step to make your changes permanent, so don’t just quit after this step.

Log into the web admin interface of your NAS and under the “System Tools” category click on “Remote Login.” Untick “Allow SSH Connection” and press “Apply.” Wait a few seconds, then tick “Allow SSH Connection” and press “Apply” again. This will reset your ssh server and if you did everything right you should now be able to login as users besides admin.

If it does not work, don’t panic. You can restart your NAS and the configuration will be replaced with the original. If you really manage to screw things up, enable telnet and log in that way to try to fix things up.

(Be careful about restarting sshd while logged in via ssh. It is very easy to kill your own connection before the new sshd starts and then you will have to use the web admin interface anyways. If you know what you are doing and are very careful, you can restart it via the shell.)

Now if everything went well, we can make the configuration permanent. We need to create or edit an autorun.sh script which moves the configuration over during boot. First mount the config area:

mount -t ext2 /dev/mtdblock5 /tmp/config

(The device may differ if you have a different model. Check Google if the last step doesn’t work.)

Next we need to edit or create the autorun.sh file:

vi /tmp/config/autorun.sh

If the file doesn’t exist or is empty, insert all of the following. If there is already a script there, skip the first two lines and add the rest at the end of the file:

#!/bin/sh

# SSH Config
cp /mnt/HDA_ROOT/.config/ssh/sshd_config /etc/ssh/sshd_config
/etc/init.d/login.sh restart

After saving it, make sure it is made executable and unmount the filesystem:

chmod +x /tmp/config/autorun.sh
umount /tmp/config

Now you can reboot your NAS and confirm that the configuration was preserved. Keep in mind that it can take 3-4 minutes to reboot. There will be a couple of short beeps during the reboot process and one longer beep when it has completed booting. Be patient and wait for the long beep before trying to login.

In the future be sure to make any configuration changes to sshd_config by editing the non-ramdisk copy like follows:

vi /mnt/HDA_ROOT/.config/ssh/sshd_config
cp /mnt/HDA_ROOT/.config/ssh/sshd_config /etc/ssh

AviSynth Plugin ReduceFlicker on x64

If you are trying to use this plugin on XP 64-bit OS you may find that you follow all the directions to install it and then run into an error:

“unable to load …ReduceFlickerSSE3.dll”

The problem is that the instructions tell you to install AvsRecursion.dll in “C:\WINDOWS\system32”. On XP x64 it should actually be installed in “C:\WINDOWS\SysWOW64”. Move it there and it should work fine.

PowerDVD 8 HD-DVD and MoovieLive Tweak on 64-bit

If you are on a 64-bit OS and having trouble getting the PowerDVD 8 HD-DVD pack and MoovieLive tweak pack to be effective, it is probably because your registry structure is different. Here’s how to fix:

HD-DVD Pack:
Edit HDDVD64.reg and change all instances of “HKEY_LOCAL_MACHINE\SOFTWARE\Cyberlink” to “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cyberlink” and then run Install64.bat again.

Tweak Pack:
Edit Disable_MoovieLive.reg and do the same changes as for the HD-DVD Pack and then add the file to the registry. DO NOT change “HKEY_CURRENT_USER\Software\Cyberlink”.