How to Install WordPress Next to Your Magento Installation

**Warning:**Installing WordPress on your Hypernode has some serious security implications: Although Magento is quite secure, many vulnerability issues are discovered in WordPress extensions. We recommend running your WordPress blog on a different server than your webshop as a security leak in WordPress causes attackers to have full access to your webshop!

Due to high demand we decided to document how to install WordPress on Hypernode. This is at your own risk!

Installing wp-cli

To install WordPress we’ll make use of wp-cli, a commandline utility to manage and install WordPress sites.

To install WordPress cli, run the following commands:

mkdir -p ~/bin
wget -O ~/bin/wp-cli https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod 0750 ~/bin/wp-cli

This will install the wp-cli utility to /data/web/bin/wp-cli

Create a Database

First create a database for WordPress:

mysql -Be 'create database if not exists wordpress'

Installing WordPress

To install WordPress on Hypernode, we’ll use the /data/web/public/blog directory.

Create a Directory

mkdir -p ~/public/blog

Download WordPress to the blog/ Directory

cd /data/web/public/blog/
~/bin/wp-cli core download --force

Unpack WordPress and Create a wp-config.php

~/bin/wp-cli core config --dbhost=mysqlmaster --dbname=wordpress --dbuser=app --dbpass=<your mysql password>

Install WordPress and Load the Database Schema

~/bin/wp-cli core install --title="blog" --admin_user="your-admin-user" --admin_password="your-admin-password" --admin_email="you@example.com" --url=appname.hypernode.io/blog/

Activate All Plugins, Sync the Database Schema and Flush the Cache

~/bin/wp-cli plugin activate --all
~/bin/wp-cli core update-db
~/bin/wp-cli cache flush

Now your Wordpress is fully installed.

Configuring WordPress to Work in a Subdirectory

To configure WordPress to work in a subdirectory, add the following snippet to the top of your wp-config.php:

$host = 'http://' . $_SERVER['HTTP_HOST'] . '/blog/';
define('WP_HOME', $host);
define('WP_SITEURL', $host);
define( 'AUTOMATIC_UPDATER_DISABLED', false);
define( 'WP_AUTO_UPDATE_CORE', true );

Configuring Nginx to Serve WordPress in a Subdirectory

Now all we need to do is configuring Nginx to serve a WordPress site in a subdirectory.

Create a /data/web/nginx/server.wordpress with the following content:

location /blog {
   root /data/web/public;
   index index.php;
   try_files $uri $uri/ /blog/index.php;

    location ~ \.php$ {
        echo_exec @phpfpm;
    }

    location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
    }
}

Visit Your WordPress Site

After installing and configuring Nginx, you can visit your WordPress at /blog/

Multisite

It is possible to setup a multisite environment in WordPress. To do this, refer to theoriginal WordPress documentation about creating multisitesand the article about configuring WordPress on Nginx.

Please note that it won’t work in all cases due to the fact that certain Nginx configurations cannot be changed. At the moment we are still looking into a solution that will work for everyone.