Pagoda Box and Bikoo

Bikoo chose to run WordPress on Pagoda Box, a powerful, inexpensive and flexible PaaS system.

In preparation for the launch of our first book, Demon Hunters: Desires of the Flesh, Bikoo began developing a website to support the launch and give some insight into our work. Choosing a CMS was straightforward. WordPress is powerful, easy to develop and highly extensible. We are not a software development house, so we chose something that matched our skills while having enough flexibility to hit the design mockup.

Deciding on the infrastructure for the website was more difficult. At first, we were leaning towards running the site on a self managed AWS cloud infrastructure. The benefits are scalability and precise control. The drawbacks are managing the complexity of the site and over paying until we reach start hitting the limits of a micro instance.

During our search, we ran across a great article about Pagoda Box on Techcrunch.

A few nicely written articles about spinning up WordPress sites sealed the deal. Pagoda Box is an incredibly powerful service provider that combines the flexibility of AWS with straightforward management tools.

The following is how Bikoo set up our Pagoda Box development environment:

Local Instance
A simplified version of the WordPress guide for setting up a local instance on macs:

MAMP

  1. Download and install MAMP MAMP website
  2. Open MAMP and go to preferences
  3. Under “Ports”, change the Apache port to 80
  4. Under “PHP”, make sure 5.2.4 is selected
  5. Under Apache, select the website root folder
  6. Start MAMP

PHPMYADMIN

  1. When you start MAMP, it will open a management window. Select phpMyAdmin
  2. Under “Create New Database”, call it “wordpress”

WORDPRESS

  1. Download WordPress
  2. Unzip and drag the contents of the WordPress folder into your document root
  3. Go to the local website (should be localhost or 127.0.0.1)
  4. Enter the following information:
    database name: wordpress
    database host/server: localhost
    database user: root
    database password: root
  5. Open wp-config.php and change line 81 from false to true to enable Debugging

Git

  1. Create a GitHub account – Free accounts only allow for public repos, so if this concerns you pay for the premium account
  2. Create a new GitHub repository
  3. Initialize the local git repo
  4. Setup a remote for the new GitHub repository

Develop!
Now that WordPress is running locally and git is set, we can start developing. Bikoo chose to use BootstrapWP as our base theme. BootstrapWP is an implementation of Twitter Boostrap designed for theme builders. It makes the process of creating a custom theme incredibly fast and is built to be responsive.

Our Tools
Eclipse IDE for web development
WPML for Multilanguage support
Sociable for Social links
Akismet to anti-spam comments
Sequel Pro
LESS

Use whatever works best for you. Once you’re comfortable with the sites performance locally, it’s time to cloudify it and send it off to Pagoda Box.

Remote Instance

Pagoda Box

  1. Sign up for a new account using the GitHub account to connect
  2. Select New Application
  3. Select Empty Repo and name your application
  4. Create a new empty text document called Boxfile in the root of your local site
  5. Add the following to the Boxfile:
    web1: #component type & number
    name: wp #component settings
    shared_writable_dirs:
    - wp-content/upload
    s
  6. Setup a new remote origin named “pagoda” in git pointing to the git address of your new app (found on Pagoda Box under Admin)
  7. Commit all changes to the local and remote repo, then git push pagoda –all
  8. Pagoda Box will automatically build the architecture and deploy the site

Database
If you navigate to your newly deployed site, there will be a connection error. Pagoda Box has not yet been configured with a Database.

  1. Go to the Pagoda Box dashboard and click “Add a New Database”
  2. Select “MySQL” as the database type and select the type (Choose the cheapest, for now)
  3. Click “Create This Database”

Setting Up Environment Variables
There are two ways to connect to the Pagoda Box database, either by hard coding the credentials or using environment variables. Environment variables are more secure, and if you plan on hosting the repository publically on GitHub, it is the only way to go.

  1. Edit wp-config with the following:define('DB_NAME', 'yourdbname');
    define('DB_USER', 'yourdbuser');
    define('DB_PASSWORD', 'yourdbpass');
    define('DB_HOST', 'localhost');
    if (isset($_SERVER['PLATFORM']) && $_SERVER['PLATFORM'] == ‘PAGODABOX’) {
    define(‘DB_NAME’, $_SERVER['DB1_NAME']);
    define(‘DB_USER’, $_SERVER['DB1_USER']);
    define(‘DB_PASSWORD’, $_SERVER['DB1_PASS']);
    define (‘DB_HOST’, $_SERVER['DB1_HOST'] . ‘:’ . $_SERVER['DB1_PORT']);
    }
    else {
    define(‘DB_NAME’, ‘wordpress’);
    define(‘DB_USER’, ‘root’);
    define(‘DB_PASSWORD’, ‘root’);
    define(‘DB_HOST’, ‘localhost’);
    }
  2. Go to the Pagoda Box Dashboard, select Global Vars
  3. Enter PLATFORM = PAGODABOX and save

Pagoda Terminal
By using the Git push, we can now publish updates to the site code, but we still need to create a way to migrate databases and push content updates. Pagoda Box requires a tunnel to be setup to connect to writable directories and the database. The Pagoda Terminal client helps us create the setup for the tunnel.

  1. Open the OS X terminal
  2. Type the following to install the Pagoda Terminal client: sudo gem install pagoda
  3. Type the following to connect to the tunnel: pagoda --app=yourAppName --username=yourUsername --password=yourPassword tunnel --component=db1

The tunnel is now open and you can connect via ssh or sftp.

Database Migration
Sequel Pro is a free and easy to use MySQL connection tool.

  1. Download and install Sequel Pro
  2. Set up a connection to your local database and Add to Favorites:Name: local
    Host: 127.0.0.1
    Username: root
    Password: root
    Database: wordpress
    Port: 8889
  3. Connect to the database
  4. Go to File -> Export and save the database snapshot
  5. Close the connection window
  6. Set up a connection to the remote Pagoda Box database and Add to Favorites:
    Name: Call it something
    Host: 127.0.0.1
    Username: Under DB Credentials
    Password: Under DB Credentials
    Database: wordpress
    Port: 3306 (Confirm on the credentials page)
  7. Connect to the database
  8. Import the snapshot from before
  9. Find the two rows in the wp_options table: site-url and home and change them to the site URL in the Pagoda Box dashboard
  10. Close the connection

We can now connect to our Pagoda Box hosted site!

DNS Override
When developing locally, we want to maintain the site-url and home values as well as permalinks in WordPress. That means we need to setup a DNS override to point bikoo.jp (Or whatever your site name is) to the localhost.

  1. Open a terminal window
  2. Type: sudo nano /etc/hosts
  3. Enter password
  4. Add DNS overrides of the form:
    HOSTNAME IP address
    bikoo.jp 127.0.0.1
  5. Save and exit

bikoo.jp will now route to the local Apache server. When we make changes to the local database, they will all be entered with the bikoo.jp hostname, so we can easily migrate the database to production.

Regular Development Workflow

  1. Open Pagoda Box tunnel
  2. Connect with Sequel Pro and export the latest snapshot from the Pagoda Box site
  3. Connect to the local database and import the snapshot
  4. Open the local website and confirm the new data has been imported correctly
  5. Begin making changes. Be sure to commit regularly and use best Git practices so you can always rollback if a feature breaks.
  6. When the changes are finished, sync the changes to the remote repository
  7. If there were any database sync the databases
  8. Push the latest code to Pagoda Box

It is a lot of steps, but once we got passed the original setup, the development process has been a cinch. That coupled with easy management and headache free migrations makes Pagoda Box one of the most exciting services we have seen in a while.

The best part: Pagoda Box’s free tier is powerful enough to run our website and it’s FREE.

If this article has been useful, check out our first release, Demon Hunters: Desires of the FleshBaku Yumemakura’s sex-filled, brutally violent Sci-fi fantasy opus.