Domain mapping with Wordpress MU, Plesk, Apache2 & Ubuntu

July 24, 2008 by mrdavidlaing · 2 Comments
Filed under: Ubuntu, Wordpress 

Given a Wordpress MU install on Plesk running on Ubuntu with Apache2, we want to configure domain mapping so that

user1 can have myblog1.com mapping to their wordpress blog (myblog1.masterwpmu.com) and
user2 can have myblog2.com mapping to their wordpress blog (myblog2.masterwpmu.com)

We need to configure quite a few moving parts:

  1. DNS for masterwpmu.com - this should be an A record, pointing to the IP of your server
  2. DNS for myblog1.com & myblog2.com - these should be CNAME records, pointing to the A record in (1) - eg. masterwpmu.com
  3. Apache2 - we need to alter the apache vhost conf created by Plesk to setup a wildcard alias
  4. WordpressMU - we need to configure it to serve the right content when receiving a request for myblog2.com or myblog2.com

When someone makes a browser request for myblog2.com, the following sequence happens:

  1. myblog2.com is resolved to masterwpmu.com, which is resolved to the IP of your server.
  2. the browser makes a request to the IP, port 80, passing the host header of myblog2.com
  3. Apache intercepts the request to point 80, checks through all its known vhost server aliases, and not finding a match redirects to the wildcard alias pointing to our WPMU install
  4. WPMU gets the request, matches the host header to the correct blog content, and returns the relevant page.

So, how do we configure this?

  1. Create a new Plesk site, with its own domain name (eg. masterwpmu.com) & install WPMU.  Ensure this works.
  2. Create a new CNAME record myblog2.com which resolves to masterwpmu.com (Its also possible to setup an A record pointing to the same IP as masterwpmu.com; although this will break if the IP of masterwpmu.com ever changes).  Google has a nice set of instructions for doing this on most major DNS providers (obviously you’ll want to point to masterwpmu.com rather than ghs.google.com ;) )
  3. Edit the Apache2 vhost conf created by Plesk at: /var/www/vhosts/masterwpmu.com/conf/httpd.include, changing:
    ServerAlias *
    <Directory>
    AllowOverride FileInfo Options
  4. restart Apache2 ( /etc/init.d/apache2 restart)
  5. Log in to the WPMU install as admin, and create a new blog.  Edit the new blog, and change the Domain & FileUpload Url to myblog2.com and http://myblog2.com/files (all the other Urls are automatically updated when you save)
  6. Browse to http://myblog2.com !

Gotchas:

  • You can only have 1 wildcard Apache ServerAlias per IP

Hope that helps!

HOWTO: Ubuntu Server 7.0.4 on VMWare Server 1.0.4 on Windows XP

October 29, 2007 by mrdavidlaing · Leave a Comment
Filed under: Ubuntu 

My local PHP/Symfony DEV environment is an Ubuntu Feisty Fawn server, running under VMWare on my Windows XP laptop. All the server side stuff runs on the Ubuntu VM, which mirrors the setup of my production host.

Install VMWare Server (free) from http://www.vmware.com/download/server/

This is a pretty straight forward Windows install, once you have registered and received the (free) license key via email

Your machine needs to have plenty of RAM, and a couple of gigs of free HDD space. (It works fine on my Dell Inspiron 510m, 1.6GHz, 1.25GB RAM laptop)

Install Ubuntu Feisty Fawn 7.04 VM

Download the installation CD ISO from http://www.ubuntu.com/getubuntu/download

Fire up the VMWare Server console, create a new VM. Use a NAT ethernet adapter. Make sure the VM’s CDROM points to the ISO you just downloaded.

Run through the installation proceedure, doing just the bare bones standard install. At the end, reboot, and don’t be alarmed at the crash:

Int 14: CR2 c1000000 err 00000002 EIP c03f3c3e CS 00000060 flags 00000006
Stack: 373c0046 00000000 ffffffff c0490000 00001400 00000080 00400000 ffffff80

The default server kernel won’t work with a VPC (http://www.virtualbox.org/ticket/289), so we need to install the desktop one.

* Re-Boot the server CD (NOT the server install), select recovery mode.
* Go through all the (recovery) steps ….
* Once you get to the command line :

# apt-get install linux-386
# apt-get remove linux-serverReboot, and login. Viola!

Finally, run ifconfig from the Ubuntu command line - to find the (current) IP address of the VM.