fbpx

Magento / Web Apps / Wordpress

Magento WordPress Multisite Nginx Integration by Fishpig

by , , revisited on


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

If you own a Magento shop, you may want to increase its SEO by adding a WordPress blog to it. But what is the best way to add it? One of the popular choices is using a Magento plugin to display WordPress blog inside Magento frontend interface. This Magento WordPress integration technique will nicely wrap the blog posts and display blog posts within your store template.
Fishpig WordPress integration plugins are best way to implement it. The Magento plugin is easy to setup and well documented.

But what if you have multi-store Magento installation, with each store residing on a different domain? And you want each store front to have its own WordPress blog. Well, they have solution for this case as well – you would create a WordPress multisite installation and then make use of additional Magento plugin “Multisite Integration“.

The latter plugin has little less documentation.

Magento WordPress integration with multiple store views and blogs

Let’s review the steps needed to integrate multi-store Magento installation with WordPress on Nginx web server.

We assume you’ve already created all your Magento stores. Suppose that we have three stores configured within single Magento installation:

  • http://aaa.getpagespeed.com/en (store view code aaa_en)
  • http://bbb.getpagespeed.com/en (store view code bbb_en)
  • http://ccc.getpagespeed.com/en/ and ccc.getpagespeed.com/ru/ (store view codes ccc_en and ccc_ru, since it has 2 views one for each language)

We want each Magento store view to have a WordPress blog, so our goal is having these pages display WordPress blog posts:

  • http://aaa.getpagespeed.com/en/blog/
  • http://bbb.getpagespee.com/en/blog/
  • http://ccc.getpagespeed.com/en/blog/ and ccc.getpagespeed.com/ru/blog/

All the /blog/ URLs will display different blog posts, of course.

First thing you need to do is to make sure that Nginx will properly rewrite requests to WordPress.
Open configuration of Magento site server block in Nginx and put the following:

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
  rewrite /wp/wp-admin$ $scheme://$host$uri/ permanent;
  rewrite ^/wp/[_0-9a-zA-Z-]+(/wp-.*) /wp/$1 last;
  rewrite ^/wp/[_0-9a-zA-Z-]+(/.*\.php)$ /wp/$1 last;
}

location /wp {
   index index.php;
   try_files $uri $uri/ /wp/index.php?$args;
}

Please refer to plugins documentation and WordPress on performing the following steps to make things work as expected. The important step is #7 for our purpose.

  1. Locate your Magento files and create /wp/ directory there. It should be on the same level with Magento’s /app/ directory.
  2. Install WordPress into /wp/ directory
  3. Install “WordPress Integration” Magento plugin. Then integrate first Magento store with the WordPress site we have in subdirectory.
  4. Convert the WordPress site into multisite
  5. Install “Multisite Integration” Magento plugin
  6. Most important step. In WordPress, create Network sites and specify site URL and home URL using these rules:
    • site URL should always point to domain of the first Magento store view. It must be in subdirectory of /wp/, i.e. /wp/store_code/ (except for the first WP site).
    • home URL should be the /blog/ URL with the proper store view domain where you expect Magento to render WordPress blog posts.

WordPress network sites for our example

WordPress site #1:

Site URL: http://aaa.getpagespeed.com/wp/
Home URL: http://aaa.getpagespeed.com/en/blog/

WordPress site #2:

Site URL: http://aaa.getpagespeed.com/wp/bbb_en/
Home URL: http://bbb.getpagespeed.com/en/blog/

WordPress site #3:

Site URL: http://aaa.getpagespeed.com/wp/ccc_en/
Home URL: http://bbb.getpagespeed.com/en/blog/

WordPress site #4:

Site URL: http://aaa.getpagespeed.com/wp/ccc_ru/
Home URL: http://bbb.getpagespeed.com/ru/blog/

Again, take note that the domain of site URLs of all WordPress blogs is the same to base Magento domain and does not vary. It’s the home URL that is domain dependent.

Magento WordPress integration with multiple sites is tricky, but using the approach described it’s pretty straightforward to implement.

  1. Bruno

    Just doing the Magento 1.9.2/Wordpress integration with Fishpig extension right now.Very interesting article, even for a amateur like me. Always happy to have Magento input….Thank you Danila

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.