Hosting multiple WordPress sites with WordPress Multisite and Domain Mapping

I use WordPress to run my blog. I recently had the need to run another site and wanted to also use WordPress as my CMS. However, I don’t want to run another installation of WordPress if I don’t have to. I followed the directions on here to create enable WordPress Multisite, and followed the directions on here to make use of a different domain name for my second site. Basically,

  • backup my WordPress database and WordPress directory first
  • enable WordPress Multisite via wp-config.php
  • disable all WordPress plugins
  • follow the install options on my WordPress site
  • re-enable my WordPress plugins
  • install the WordPress MU Domain Mapping plugin
  • continue with instructions here

Some things specific to my setup:

  • sub-domain was enabled by default from my previous WordPress installation; I had to add the CNAME * to my Host DNS configuration, where is my current WordPress site. I also had to add the line ServerAlias =* to my VirtualHost setup my Apache web server configuration.
  • mapped my WordPress site 2 from to, where site2 is the name of my new WordPress site.

Now I am able to host multiple WordPress sites from the same WordPress installation. What is the down side? I have to manage plugins and themes that are available for each of the site…

Create a website instead of a blog from WordPress using the right theme

WordPress is no doubt a great blogging platform. However, it is also a user-friendly Content Manangement System (CMS) that can be used to run a website. However, you have to tweak it to not look like a blog and more like a traditional website. The easiest way to do so is probably through an appropriate theme. I ran into the Phanatics theme, which looks very asthetically appealing with a monetary fee for its license. I also found the free Weaver theme to also be good looking.

For basic sites that I don’t want to host, I’ll probably still be using Google Sites. For sites that I want more control over and be able to host, I’ll rely on WordPress with an appropriate theme.

Some modifications for WordPress

I recently changed my WordPress theme to Reflex+, a theme that resembles the current look of Google+ and other Google related services. I had to make some manual modifications.

Excerpt vs. full content for each post

On the main index page, you can either show just an excerpt or the full content of each post. I like the full content. To get the index page of your current theme to show the entire content of each post, find a line in ./blog/wp-content/themes/reflex-plus/index.php similar to


and change it to


My changes:

»').''); */ /*vinh: display full content instead of summary */?>
»').''); ?>

Edit link style

I don’t like it when links are not visually different than normal text. I followed this post and modified ./blog/wp-content/themes/reflex-plus/style.css: a:link {
color: #09C;
} a:visited {
color: #006;
text-decoration: none;

Adding instructions or comments to the comments section

I wanted to give instructions on writing Markdown Syntax, source code, and LaTeX near the comments box. I modified ./blog/wp-includes/comment-template.php as follow:

/* 'comment_notes_after' => '

' . sprintf( __( 'You may use these HTML tags and attributes: %s' ), ' =' . allowed_tags() . '=' ) . '

', */ /* vinh */
'comment_notes_after' => '

Use [[][Markdown Syntax]] for markup.
Surround blocks of code with 
. For syntax highlighting of specific languages, use the appropriate "brush alias" from [[][this]] list. For example, surround php code with
. LaTeX code can be surrounded by "backslash left parenthesis" and "backslash right parenthesis" or "backslash left square bracket" and "backslash right square bracket". ',

WordPress’s Syntax Highlighter Evolved messes up my code

I use email to post entries to my blog. I place code snippets in between “LEFT BRACKET plain RIGHT BRACKET” and “LEFT BRACKET /plain RIGHT BRACKET” with the “div” tag surrounding them. My code gets displayed fine using the Syntax Highlighter Evolved plugin. However, when I edit the entry in wordpress, quotes, ampersands, less than signs, and greater than signs get converted to html code when I save the post and it makes my code unreadable. This also happens if I start writing my post in wordpress. This only happens to text within the code chunk, and not text outside of it. This conversion that happens when saving does not happen when the plugin is disabled. I did not find a fix for this.

To edit my posts with code and not have them messed up when saving, I have to disable the plugin before editing and re-enabling after editing. This is a pain.

For the previous posts that are already messed up, one can execute a sql script to replace the funny html code. For me, I edited each post manually in emacs and made use of this function:

 <pre class="example">(defun undo-html-char ()

(interactive) (beginning-of-buffer) (replace-string “<” “<“) (beginning-of-buffer) (replace-string “>” “>”) (beginning-of-buffer) (replace-string “&” “&”) (beginning-of-buffer) (replace-string “”” “\””) (beginning-of-buffer)

LaTeX or MathML on the web via MathJax

I recently discovered GmailTeX, a plugin (implemented via javascript) that displays LaTeX markup in my emails viewed through my web-based gmail account. SIDE NOTE: I implement it conkeror by creating a webjump for the bookmarklet code.

GmailTeX renders the LaTeX markup via MathJax, “an open source JavaScript display engine for mathematics that works in all moder browsers.” What I like about MathJax is that it displays the math symbols as actual characters as opposed to generating an image with all the math symbols (as implemented in, e.g, wp-latex). The display is really nice. What I REALLY like about it is that you can right-click on the math and export the raw code in LaTeX or MathML; the right-click even works in conkeror. That way, the reader can easily adapt your code without having to re-write them should it become necessary.

For WordPress, the mathjax-latex implements it finely; the syntax is also described here. To illustrate its power, let me state one version of the most important theorem in all of statistics, the Central Limit Theorem:

Suppose \( X_1, \ldots, X_n \) is a sequence of independent and identically random variables with \( E(X_i) = \mu \) and \( \text{var}(X_i) = \sigma\^2 \). Then

$$ \sqrt{n} \left( \frac{1}{n} \sum_{i=1}\^{n} X_i – \mu \right) \stackrel{\scriptscriptstyle d}{\longrightarrow} \mathcal{N}(0, \sigma\^2). $$

Amazon EC2 free hosting (micro instance) for 1 year – Ubuntu + WordPress + Asterisk

I use old laptops as web servers at school. However, they really aren’t built to be running continuously; I have disk problems on both of my old laptops. Amazon Web Services offer a free usage tier of EC2 cloud service for 1 year. After the 1 year, the micro instance cost about $.02/hr, which is still pretty cheap. I sign up for an account with Amazon Elastic Compute Cloud (EC2), started an instance, installed the ami-3e02f257 AMI, downloaded the private key, and the ball started to roll. Before you can ssh to your server, you have to set up the firewall from the management console of EC2 to open port 22 per this post. To log in and set up, I had to download the private key (PEM) that amazon generated and logged in as the user ubuntu (root is not allowed for my chosen AMI; this is the default user per the AMI):

<pre class="src src-sh">ssh -i /path/to/amazon.pem ubuntu@permanent.dns

Once logged in, I changed the ssh configuration to allow user logins. Then, I created my user account:

<pre class="src src-sh"><span style="color: #ff4500;">## </span><span style="color: #ff4500;"></span>

sudo useradd -d /home/username -m username ## create user sudo passwd username ## set password

## sudo adduser username admin

## sudo emacs -q -nw /etc/passwd ## change /bin/sh to /bin/bash

Now I can log in with my username, and enable passwordless ssh.

Now that Ubuntu is set up, I can install everything I want subject to the constraints of the server. Let’s see how this goes…

WordPress and MySQL – error establishing a database connection

My server’s been going down quite often recently (once a week). I believe it is a problem with the disk. Usually rebooting the server makes everything (including my blog) work again. Recently, I got the message “error establishing a database connection” even after the reboot. After many tries, this worked for me. Basically, my options table (prefix_options) was broken. Fixing it using phpMyAdmin worked.

Before fixing the database, I thought it was a disk error. I tried using the Linux Rescue Disk to fix the disk based on this, but badblocks didn’t report anything back, and I couldn’t use fsck. I’ll give it another try if the problem persists.