Click here to Skip to main content
Click here to Skip to main content

Wordpress Azure Mµ

, 26 May 2013
Rate this:
Please Sign up or sign in to vote.
Wordpress Azure Mµ, Wordpress Multisite on Azure

Please note

This article is an entry in our Windows Azure Developer Challenge. Articles in this sub-section are not required to be full articles so care should be taken when voting. Create your free Azure Trial Account to Enter the Challenge.

Introduction 

Wordpress Azure Mµ is some custom changes to the basic wordpress install, that better take advantage of what Azure offers and to allow Wordpress Multisite on Azure.  

http://helixten.azurewebsites.net/ 

Background 

So out of the box azure supports wordpress. That is great but it is missing some great features to full use the power of Azure. Also there are some "bugs/missing features" That need to be addressed. Like it does not work with Wordpress Multisite out of the box. Also it is not setup to use the Azure blob storage or Sql Azure.  

How Azure might benefit the project?   

The benefits of using azure is the scalability and the flexibility. Use azure I don’t have to worry about one site getting slash doted and bring down the whole network.

Let Begin!

To start of create a site and using the Azure gallery create a wordpress site. Just follow the steps boom done! Well not quite… After the install is done, pick what feature you want to add below! 

Custom Changes 

  • Wordpress Multisite with multi-domain support  
    To add multisite add the /* Multisite */ code to your wp-config.php Make sure SUBDOMAIN_INSTALL is false! Next install the WordPress MU Domain mapping plugin this will make the domain name to the right site. Follow the plug steps to move the sunrise.php to the right place afterward add /* for domain mapping */ code to the wp-config.php. Then In the Azure control panel make sure you add all the domain names. Boom Done! You can add sites to your wordpress   
  • Azure blob for storage 
    I really recommend this! To use blog storage to host your image add Windows Azure Storage for WordPress plugin. It is really easy to setup. If you are using multisite do not “Network Activate” That won’t work just enable it on each site.  You can also use the cdn using this plugin!  
  • Stop All The Error Print Outs 
    Php on Azure print all warning and errors. While that is great for debugging it is not good for a site in production. Some pluld will display pgp Notice print outs to turn it off add the line below to the php page;   
    error_reporting(E_ALL ^ E_NOTICE); 
     
  • Sql Azure for the database (instead of the default of ClearDB)
    • The default setup for wordpress on Azure uses mySql provided by ClearDB. The problem is that the max database size is 20mb.  To setup wordpress to use sqlAzure you need the plugin below
    • http://wordpress.org/plugins/wordpress-database-abstraction/ 
    • Download and unzip the plugin to /wp-content/mu-plugins/
    • Then run:
    • http://yourSite.azurewebsites.net/wp-content/mu-plugins/wp-db-abstraction/setup-config.php 
    • Make sure to select PDO SqlSrv as database type, not “SQL Server using MS PHP Driver” 
     
  • Cache  with cdn 
     Coming Soon... 

Using the code 

Web.config To Use Multisite

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="(^[_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 7" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
      <security>
            <requestFiltering>
              <requestLimits maxAllowedContentLength="104857600" /> <!--100 MB-->
            </requestFiltering>
          </security>
    </system.webServer>
</configuration>  

 wp-config.php  Add this for multisite   

 
/* Multisite */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
$base = '/';
define('DOMAIN_CURRENT_SITE', 'YOUR SITE');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

 Add After  WordPress MU Domain Mapping is installed 

/* For domain mapping */
define( 'SUNRISE', 'on' );  
Add TO Plugins That print errors.
error_reporting(E_ALL ^ E_NOTICE);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

HelixTen
CEO Helix Ten
United States United States
I am the creator of last year contest winning app Loclville. I have been programming for 10+ years. I work as a software engineer at Sony Picture Imageworks. (One of the world largest effects house.) JavaScript and Python are my strongest languages, but I also use php and c#. I have created few app in the app stores for Windows 8, 7, Windows Phone, iOS, Android and Blackberry.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 27 May 2013
Article Copyright 2013 by HelixTen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid