Install WordPress next to your Magento installation

in Usage

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 the original WordPress documentation about creating multisites and the article about configuring WordPress on Nginx

0