WordPress Multisite Using CloudFlare on Individual Blogs

Trying to set up a WordPress Multisite using CloudFlare on individual blogs? I was. I just moved a WordPress (WP) Multisite subdomain installation and wanted to take full advantage of CloudFlare CDN for each for each of the sites blogs. It’s an awesome service, and free!

Using the lazy route of enabling CloudFlare on my domains via hosting control panel, it requires the www domain name prefix to invoke it’s magic. But the file uploads in a WordPress multisite don’t automatically include this magic.

By default, media uploaded through WP uses the path http://subblog.primaryblogdomain.com – we want to change that to http://www.blogname.com to be served up by CloudFlare.

How-to Instructions for setting up WordPress Multisite Using CloudFlare

In the WP backend (as Super Admin), on the toolbar, go to My Sites/Network Admin/Sites

Edit each site that has been set up on CloudFlare, and select the “Settings” tab.

Change the “site URL” field to be your fully qualified CloudFlare domain, as in http://www.blogname.com and note the blog ID number, from URL when you’re editing each blog. It will end with “site-settings.php?id=X” and we’ll make use of it shortly.

Test an upload to see it uses the proper url. Boom, it’s set!

If you are doing this on an installation that has been moved (i.e. already has posts), you’ll also need to update the posts table in the database. I like to use PHPmyAdmin for this. Hint: Backups are your friend!

Here is the query you’re looking at, where “X” is the ID of the wordpress blog if your tables are named named as mine are; you can easily identify each blog’s ID

UPDATE wp_X_posts SET post_content = replace(post_content, 'subblog.primaryblogdomain.com/wp-content/uploads/', 'www.subblog.com/wp-content/uploads/');

I would suggest leaving the upload path in the SQL command so you don’t inadvertently change something you didn’t want to change. Also, be sure it’s a correct upload path for your setup!

After you’re done, you can also add the CloudFlare WordPress plugin to see to it your stats and so forth accurately reflect your visitors’ locations. You will need to configure the plugin on each site of your installation individually.

I found I also needed to re-save my permalinks in some cases. I’m not sure if it was this operation that created the need or not. I was doing a lot of work on my install at the time, but if you’re getting 404 errors with post titles, give that a try.

That’s it–configuring Wordpress Multisite Using CloudFlare is not so difficult.   Unless you have some image paths hard-coded in your themes, plugin or widget code, your WordPress should now serve all your images from Cloudflare instead of the local server. No plugins, no headaches. Just a little configuration change and some mySQL voodoo.

FYI, this information is offered AS IS, in the hopes it is of help to someone. If you break your Wordpress, I cannot fix it for you. I cannot answer WP support questions. This is what worked for me, period. Thanks for understanding.

Share Button

Manually Adding an Admin User to a WP Database

Lost your admin password? Need in to the WP admin but client hasn’t given you access? If you can access the database directly–easiest using a tool like PHPmyAdmin–you can give yourself whatever access you need.  ((Big hugs and kisses out to DNA Web Agency for this uber-helpful information lifted for this tutorial.))

Locate the right database–if you have FTP, looking at the wp-config.php file at the root of your WP installation is the fastest route. Otherwise, if you have multiple WP installs, check out the options table to match urls and make sure you’re looking in the right database.

In your wp_users table, you insert a new record:

  1. user_login –username to access WordPress
  2. user_pass – password – be certain to select MD5 from the phpMyAdmin Function dropdown menu; it’s stored encrypted)
  3. user_nicename – how you’d like to refer to yourself, not login
  4. user_email – email for this user
  5. user_url – optional
  6. user_registered –  just select a date
  7. user_activation_key – leave this blank
  8. user_status – leave this set to 0
  9. display_name – what displays, can be same as nicename

Note the user ID, as you’ll need it for the next steps.

To give yourself access permissions, head on over to insert a record into the wp_usersmeta table.

  1. umeta_id – automatically generated
  2. user_id – ID of the user you just created
  3. meta_key –  wp_capabilities
  4. meta_value copy and paste this:

[code]a:1:{s:13:”administrator”;b:1;}[/code]

Insert another row, with this information:

  1. umeta_id – automatically generated
  2. user_id – use the ID you created
  3. meta_key – insert wp_user_level
  4. meta_value – insert 10

Save your work and go log in!

Share Button

Setting Up Wildcard DNS for WPMU on cPanel

Allowing people to set up blogs for WordPress MU at blog.domain.tld requires installing your WPMU in the site root and setting up wildcard DNS. In setting up my first WPMU, I ran across this tutorial by Matt Mullenweg of WordPress fame, linked from the WordPress MU docs.

Since I’m not the queen of DNS or anything, I checked with my admin folks to make sure I got the Virtual Host entries correct. I found out this is extremely easy to do if you have a cPanel setup.

Here’s How from my SysAdmin:

To add wildcard DNS and vhost settings in one swoop, simply add a new sub domain to the account and name it ‘*’ (the asterisk character). Make sure it’s document root is pointed to the same directory that your WordPress MU is setup in and cPanel will add everything else to all of the configuration files.

Sure enough, worked like a charm, took 30 seconds, and didn’t require anything scary like restarting Apache–there is no time that runs slower in the time-space continuum than waiting for httpd to restart, man.

Share Button