Category Archives: geek stuff

WordPress multi-user on PLESK (howto)

I’ve recently been tasked with setting up a WordPress Multi-User (WordPress Mu) instance running on a PLESK based web-server. For the most part this is fairly straightforward, however WordPress Multi-User likes to let users setup blogs as subdomains of the main site, for example, the blog for “RoadRunner” would be viewed by visiting

This presents a problem for PLESK as it manages Virtual Hosting (vhosts) very carefully and it will treat this as an entirely separate domain. The way to solve it involves 2 techniques: setting up a wildcard DNS entry and adding in a special configuration file to the PLESK domain. Here’s how to do it:

Wildcard DNS entry

  • go to your PLESK control panel
  • select your domain
  • click on the DNS settings icon
  • PLESK DNS Settings

    PLESK DNS Settings

  • Now create a new wildcard entry with the following details:
    Record Type: CNAME
    Domain name: *  (the rest of the domain is written outside the textbox eg.
    Canonical name:
  • Click OK
  • When you make a change to the DNS, PLESK won’t actually apply it until you hit the UPDATE button, this is sometimes obscured off to screen right

VHOST config
The next part involves having root access to the web server. If you control the whole PLESK domain, this is possible, however you may have to make a technical request if you don’t

  • using Terminal, logon to the server with SSH (eg ssh enter your password and you should be presented with a command prompt
  • cd to the correct folder for your domain (usually /var/www/vhosts/
  • cd into the conf folder
  • create a new file, using vi
    vi vhost.conf
  • press i to go into insert mode and enter the following line:
    ServerAlias *
    (where is your domain)
  • hit ESC and then tap :wq! to save the file and quit
    You may also be able to create this file using your favourite web editor – mine is Coda from Panic software – and FTPing it up into the conf folder one level up from the root of the web site, however you will still need to be able to restart the PLESK instance to get it to read the new file.
  • in the command prompt, type the following command:
    /usr/local/psa/admin/sbin/websrvmng -a -v
    this will restart PLESK

That’s it. You should find that you can now create blogs and view them in their dedicated subdomains.Православни икони

serving Microsoft Office 2007 documents from a Linux PLESK web site

Office 2007 introduced a whole host of new application extensions, most of which aren’t recognised by the Apache web server.

What happens if you link to a downloadable file can often be unpredictable; Firefox on OS X will merely download the file. Internet Explorer on the other hand – even on a system that has Office 2007 installed – will attempt to treat the file as a compressed file.

Download dialog showing incorrect file type

Download dialog showing incorrect file type

Once you choose save in Internet Explorer, it saves it as a compressed file which when you open it gives you a set of resources, similar to a Mac Bundle. It’s pretty hard to actually get the correct application to launch and run the file as it should (the example above was a PowerPoint pptx file).

Luckily, help is at hand and all you really need to do is register the new Mime types with Apache. You can either do this at the server level in the Apache configuration file, or on a per-site basis using a .htaccess file.

Apache config file
This file is called httpd.conf for Apache 1 and apache2.conf on Apache 2. There are a number of places it can be so it’s best to run a file search on the server to find it.

SSH into your server as root (if possible)
Run the command  find / -name apache2.conf or    find / -name httpd.conf
You should now see a file listing which will give you a clue as to where the file will be (most likely etc/apache2 for Apache 2 web servers).
Edit the file using the command vi /etc/apache2/apache2.conf (if that’s where the file is)
Type :10000 to jump to line 10000 (and therefore the end of the file)
Press I to insert and then newline
Paste in the following lines:

AddType application/ .docm
AddType application/vnd.openxmlformats .docx .pptx .xlsx
#AddType application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx
#AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
AddType application/ .dotm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template .dotx
AddType application/ .potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template .potx
AddType application/ .ppam
AddType application/ .ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow .ppsx
AddType application/ .pptm
AddType application/ .xlam
AddType application/ .xlsb
AddType application/ .xlsm
AddType application/ .xlt .xla
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template .xltx
AddType application/ .xltm
AddType application/ .xps
AddType application/application/ .ppt .pot .pps .ppa
AddType application/msword .doc .dot

Now hit [Esc] to leave insert mode
Type :wq! to save the file
Finally restart the apache server, most likely by using the command /etc/init.d/apache2 restart
Your entire web server should now be able to deliver the correct file types – problem no more.
Per site .htaccess configuration
Browse to your remote site and open the .htaccess file if it’s present (make sure that your web / ftp client can see hidden files as dot-prefixed files are traditionally hidden from view on the Linux / Unix platform.

Create a new file if there isn’t one present and then simply add in the following lines:

AddType application/ .docm
AddType application/vnd.openxmlformats .docx .pptx .xlsx
#AddType application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx
#AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
AddType application/ .dotm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template .dotx
AddType application/ .potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template .potx
AddType application/ .ppam
AddType application/ .ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow .ppsx
AddType application/ .pptm
AddType application/ .xlam
AddType application/ .xlsb
AddType application/ .xlsm
AddType application/ .xlt .xla
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template .xltx
AddType application/ .xltm
AddType application/ .xps
AddType application/application/ .ppt .pot .pps .ppa
AddType application/msword .doc .dot

save the .htaccess file and your web site should start delivering the correct file types!

Now in pptx format

Now in pptx format!

NamesCo Zeus server, 301 Redirects

Howto manage a 301 redirect on a NamesCo linux (Zeus) server

I felt I should write this up because it’s a problem that’s been puzzling me for some time and I only found out the answer today. Here’s the deal:

* it’s currently recommended that all traffic to a web site goes to one URL, to minimise dilution of the Google PageRank.

* on NamesCo servers, traffic is automatically routed to both and

* ordinarily I would use an Apache .htaccess script with a simple 301 redirect in it, like so:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*)$1 [R=301,L]

* But…. NamesCo servers don’t run on Apache, they run on Zeus

So what we need is a script that will force Zeus to do the same kind of redirect.

There’s just one other gotcha, that is specific to NamesCo. The script is only allowed to be run from one place, in the root of your web directory, a file called rewrite.script. You can edit this manually but by far the best way to manipulate it is via the control panel on the NamesCo server. There’s a module under Scripts & eCommerce called Rewrite Script.

Screen grab of NamesCo control panel

Screen grab of NamesCo control panel

This module has two key features:

1) it will take standard UrlRewrite code from an Apache .htaccess file and convert it to Zeus compliant code.

2) it will allow you to type in Zeus compliant code and validate it before writing it to the server root.

After much scrabbling around and an awful lot of trial and error, I found a post from a guy called Robert at that seemed to do the trick. The original post is up on the zeus community knowledge hub.

Zeus uses a completely different algorithm for its server control scripts and documentation is somewhat thin on the ground – most of the examples I found on the internet were just that, examples and hacks showing different approaches to solving pretty much the same problem.

I’m going to repeat Robert’s script here but add in a bit of background detail to show what it is actually doing

# begin rule, rules are separated into blocks in the Rewrite.Script
match IN:Host into $ with ^example\.com$
# examine the hostname to see if it doesn’t begin with www (note the backslash to escape the dot before the domain suffix)

if matched then
match URL into $ with ^/(.*)$
# if there is a match, extract the rest of the path into a temporary variable ($1)

set OUT:Location =$1
# now re-construct the header location, this time prefixing it with ‘www’

set OUT:Content-Type = text/html
set RESPONSE = 301
# tell Google (& others) that this page has been permanently moved, so they update their records

set BODY = Permanently Moved
# human readable version of ’301′ message

goto END

# end rule

OK, so there you have it. That’s how to do some basic Zeus wrangling. There’s more documentation on the Zeus server at the Zeus Knowledge Hub web site. I think the key documentation is the TrafficScript Guide but I’m not entirely convinced.

Additional: DRUPAL users
There’s also a complete Rewrite.script for Drupal users. Get it from the main Drupal web site.

Fun with icons in OS X

OK, I’ll fess up – lately I’ve become a bit bored with the icons that appear in my OS X dock. I mean, they’re cute and all but they barely even drink. Look at the them. They’re a bit tired, eh? And I’ve always hated that Safari icon. I mean look at them
Leopard dock icons

Leopard dock icons

So I thought I’d have a play around and see how easy it was to change them. Turns out it’s really simple…

Getting the image
I decided to replace my icons with pictures of letters – just so I had a clue as to what applications they represented, so I trawled through Flickr, searching for ‘letter a’, ‘letter t’ and the like. When I found a suitable image, I used Command-Shift-4 to do a cheeky screen grab. Replacement icons can come from anywhere.
Changing the application icon
This is really easy. Open Applications in Finder and click on the application you want to change the icon for. Hit the Command-I or right-click and choose Get Info on the file to view its details.
Get Info

Get Info

double-click on your saved screen grab to open it in Preview then Command-A to select all and then Command-C to copy the image. Back in the Get Info pane, clicking on the icon itself will highlight it with a blue glow. Clicking Command-V will paste your new icon in its place. Careful though, it can be pretty addictive!


And here’s the end result. My graphitti dock! OK, it’s a bit more rough and ready than Apple’s work of art, but it’s all mine and I like it!
my dock!

my dock!

Internet Explorer 7/Opera 9 form button gotcha

Well I thought I’d kick off the New Year by documenting an annoying and frustrating “undocumented feature” of IE and Opera.
This one is pretty simple and I guess it’s fairly obvious when you think about it but it’s not consistent with other platforms or this web developer’s expectations of browser behaviour.

Internet Explorer 7 and Opera 9, as far as I can tell do not send the form element details correctly when the form is submitted. Instead of posting the input element name and value, they post the input name with the x and y co-ordinates of the mouse pointer at the time of clicking. This information is also sent by Firefox and other browsers but they do send it together with the actual element name and value as well.

Important information e.g. the Value of the button could be missed by these browsers

The real gotcha is if you are processing a form and performing alternate actions when a button is clicked on (eg you may have an ‘Upload Image’ button and a ‘Finish’ button). Testing that the button has been clicked by looking for a POST or GET value of the button name will not give you the correct result when the button was clicked in IE.

To replicate this behaviour:

Create a form and add a graphical submit button to it, with a name of “submit”

Form with graphical input button

Form with graphical input button

you would expect that as it’s an input source that the submit value will be transmitted as part of the form.

Here is the output displayed when the form is submitted to this simple script

this is what you see when you View Source in Firefox and Safari

Output from Firefox

Output from Firefox

output from Safari

output from Safari

see the final value – submit (the button) has a value of “submit”

now lets View Source in Internet Explorer 7 and Opera 9

output from Internet Explorer 7

output from Internet Explorer 7

output from Opera

output from Opera

nada – zip, zilch, nothing

As far as I know, when you create an input element in a form that element has to pass its value by name, eg. last_name=layfield otherwise it is not behaving correctly.

MySQL Tip of the day (GUI Tools, Remote access, Complex Passwords)


If you can’t remotely connect to your MySQL server using Query Analyser / Administrator GUI Tools, try replacing your password with a simpler one, as the GUI Tools just ain’t that clever.

It’s taken me around 20 minutes to realise that MySQL GUI Tools running Mac OS X do not appear to like complex passwords, such as this one


I honestly thought I was being more security aware by using this rather than my usual fairly memorable passwords but it appears that the GUI tools trip up over some of the characters (probably the ‘@’ signs), so that even though I can access the server using these credentials in an SSH session, the same login information will generate the ubiquitous MySQL “can’t connect” error.

Cannot connect to MySQL instance

Cannot connect to MySQL instance


Subversion for web design – how we do it @ Karyx

Update: Dreamweaver CS4

The latest version of Dreamweaver (CS4 currently) now has integrated Subversion support, thankfully, which means that cloaking the .svn files is no longer necessary as DW will ignore them by default. You can configure the site to connect directly to your subversion server but in our experience unless that is a repository on the local network, it adds a painfully long pause every time you try to open a file whilst it’s checking it out from the repository. Better to use Tortoise or Versions, methinks but plus points for Adobe for incorporating this feature.

Subversion using Versions, Tortoise, Beanstalk & Dreamweaver

You can set up your own local subversion server but we find it’s easier to have our Subversion repositories hosted on the net – that way we can access them at any time. Here at Karyx we use a service called Beanstalk ( ) – it lets you have a number of repositories for free and shows in a very pleasant and picturesque way all the changes that have recently taken place on the repository. You can even use it to compare different versions of files, to see where a change may have been made.

We recommend TORTOISESVN for pc (it integrates directly with Explorer in a context menu) or VERSIONS for mac (Versions is a brilliant piece of easy-to-use and well-engineered software). Get them here:



Setting up a local repository can be a bit of a faff but once it’s in place, it’s pretty painless to use. Our recommended method is:

1. create an empty repository on the server (beanstalk)
2. check it out locally to a new folder on your development machine
3. copy your project files into the new folder
4. highlight the files, right-click and choose “add” to add them into your repository
5. “Commit” the files

Note that when you check out the repository, it will ask you for a destination folder. Bear in mind that both TortoiseSVN and Versions will create a subfolder with the name of your repository in it, in whichever destination folder you choose, so you can nominate your root ‘Projects’ or ‘Sites’ folders as a destination. I know this sounds a bit arcane but if you create a dedicated folder to put the repository in, you will very likely end up with a path like


Now you will find you have a local subversion repository that is connected to the subversion server. Any file changes within this folder will now be tracked, although you will have to “Commit” any changed files to the subversion server to make the changes official.

Subversion maintains a repository – it keeps a collection of hidden folders on your local machine that contain hashes of all the files. Whenever a file is changed from the most recent version, it makes a note of this and then when you do a “Commit” – to post changes up, it pre-selects all the affected files. You can write a comment by each commit and this is recommended as it helps when you are reviewing changes to find out what exactly you did three months ago. You can also choose to “Ignore” files and folders (3rd party applications or javascript frameworks, etc).

When other users make changes to the files, you should highlight your local folder (in Explorer | Windows), or choose the working directory (in Versions | Mac) and then choose “Update” to go and grab the latest version of the changed files. Versions helpfully indicates remote file changes in it’s file list.

Dreamweaver works pretty well with Subversion and Subversion wipes the floor with Dreamweaver’s Check-in/Check-out features. There’s a 3rd party extension you can install to do Commits and Updates but our preferred method is to use the software described above.

One thing though – if you are testing your code by deploying to a remote server and you select a folder to upload, Dreamweaver will also upload the hidden version control folders (.svn files) – not good. A work around is to download and install this extension:

This works by cloaking the subversion folders, so you need to have cloaking enabled in Dreamweaver. Also it’s not automatic, so when you have your basic site checked in to Subversion, you need to go to the Commands menu and then choose Cloak SCM Directories option. You will need to do this whenever you create a new directory. Alternatively, just make sure you upload selected files and not folders.


There’s a definitive guide to subversion here:

or a “designers” guide here:

and here’s some advice on commenting your commits:

I hope this all helps. Subversion is definitely worth getting into if you want to stay confident in your code!

JQuery 1.2.6 quirk in Internet Explorer 7

I’ve been doing a lot of work lately with JQuery and I love it… I really do, it’s a great piece of code, nay, framework, that strips out all the pain of working with JavaScript and provides a launchpad for great code and interface adventures.

Nonetheless, it’s not without its headaches and recently I lost a few hours to trying to figure out why my JQuery functionality refuses to work on Internet Explorer 7. It’s very frustrating, as everything works perfectly in Safari and Firefox and then as soon as IE comes up the site goes suddenly two-dimensional with none of the interesting UI customisations that JQuery makes so much fun to build.

After a bout of head scratching, coupled with the realisation that JQuery 1.2.3 works fine I started to experiment with the way the script was invoked, fearing that IE had some kind of issue with it.

Sure enough, that was the source of the problem and as soon as I changed my JQuery initialiser to run the “old-fashioned” way, the scripts came magically back to life. So here it is:

If you’re having problems running JQuery in IE, open your html and look for the following lines

and change them to this. Be sure to check the closing part of the script too, as that is different

hopefully the JQuery developers will sort out that problem in time for the next version…

JavaScript forms submit gotcha!

I’ve just lost about an hour and a half of my life to a cheeky little JavaScript gotcha. I thought I’d document it here in the vain hope that it didn’t get anyone else.

If you have a button on your form that is named “Submit” then beware! As soon as this button goes into the DOM, it will over-ride the form’s Submit() method, meaning that you can no longer call that from JavaScript or JQuery or whatever you are using.

Make sure you give the button a different name, or even no name at all, for your own peace of mind!икони

Parallels Plesk 8.4 Ubuntu speeding up SMTP

If you’ve used PLESK for any great length of time, you’ll know that whilst it is a great bit of software, for some reason it defaults to doing Reverse DNS lookups whenever a client connects to it to send mail.

Yeah rDNS is a useful tool for stopping spam and the like… but it also means that every single email sent takes 26-30 seconds to go out. That’s frankly unacceptable when you are trying to operate a commercial service and vastly undermines any possible benefits from it.

The good news is that it is (fairly) easily resolved. All you have to do is put in a command-line flag to tell the mail server not to perform an rDNS lookup. The hard part is figuring out exactly where to stick it.

Up to version 8, I used to refer to this handy guide, which resolved the problem though in ways I couldn’t quite understand! see here at

PLESK 8.4 introduces some major under-the-hood improvements, one of which is a subtle reorganisation of where the commands are stored. After some handy support from our ISP CWCS, we found that the command had moved to here:


and all you have to do to switch off rDNS is to insert the following flag after the second occurrence of the phrase “tcp-env” in your inetd.conf.


More info and some other useful tips here

Anatomy of -Rt0
What does -Rt0 mean exactly? Well it’s a command that’s issued to the TCP server and it tells it to

R – Do not attempt to obtain $TCPREMOTEINFO from the remote host.
tn – Give up on the $TCPREMOTEINFO connection attempt after n seconds. (default is 26 seconds ho, hum)

The complete howto

  1. Login to your PLESK server using SSH
  2. type the command vi /etc/inetd.conf
  3. type the letter I (to insert)
  4. find the two lines that begin with smtp stream and smtps stream
  5. look for the second occurrence of tcp-env
  6. type -Rt0 into the line (note zero, not ‘o’)
  7. hit [esc]
  8. type : (shift-colon)
  9. type wq! (meaning write the file and quit from vi)
  10. hit [return]

now all you have to do is restart inetd, which is done on Ubuntu by entering the command

/etc/init.d/xinetd restart

You should now find that SMTP mail sending is lovely and quick. Phew!

Please note that making some changes in the PLESK domain control panel will reset this command line, so you may need to edit it again if you start to notice delayed SMTP sends