WordPress on dotcloud

Posted by clsung on Wednesday, February 15, 2012

My AWS EC2 free tier is expired, so I switched to a fully-dotcloud-hosted site (originally I’ve host MySQL on dotcloud). Here are some notes we need to take care.

First, create a new directory and execute ‘dotcloud create’ command:

% mkdir blog
% cd blog
% dotcloud create blog

Second, download latest wordpress tar ball and unpack it:

% curl -O http://wordpress.org/latest.zip
% unzip latest.zip

Since I prefer to isolate the whole wordpress directory from root directory, here is the dotcloud.yml I used:

www:
  type: php
  approot: wordpress # <- latest.zip unpacked in here.

According to official documentation, the nginx.conf contains only one line:

try_files $uri $uri/ /index.php;

So the current directory look is:

% ls -al 
.		..		dotcloud.yml	nginx.conf	wordpress

Next, put the postinstall script (with chmod u+x) in wordpress/:

!/bin/bash
if [ -d ~/data/wp-content ]; then
    echo "have old data"
    mv -n ~/current/wp-content/plugins/* ~/data/wp-content/plugins
    mv -n ~/current/wp-content/themes/* ~/data/wp-content/themes
    rm -rf ~/current/wp-content
else
    echo "create data"
    mkdir -p ~/data/wp-content
    mv ~/current/wp-content ~/data
fi

cp -Rp ~/data/wp-content/* ~/current/wp-content/ # <- I use cp instead of ln here because the dirname() problem

Finally, modify your wp-config.php properly, then push to dotcloud, rock!

dotcloud push blo