Leveraging Localhost WordPress for Learning Webmaster Skills

(Reading time: 10 – 16 minutes)

Long time readers know I run several testing installations of WordPress right on my own computer. This is colossally useful for a number of reasons:

  1. New versions of WordPress are easily installed and tested
  2. New plugins and themes can be developed and tested.
  3. Reduces risk of destroying production installations.
  4. And finally, I can learn new skills in a safe, no-risk environment.

If you have been following along in this series, you will have installed Apache, MySQL, PHP and WordPress independently from separate installer packages, and your configuration should be very close to mine. You should have a working WordPress installation, which means MySQL and PHP work essentially correctly.

As it turns out, your Apache configuration is going to be bare bones, and set to very strict default behavior. This is a good thing. Better to learn how to relax your web security incrementally, than to get your web security beat upside your head by malicious exploits. Of course, running from localhost, it’s not that big of deal… if you get hacked you can just get off the network and deal with it. Thus, in addition to WordPress, we’re going to learn some Apache magic as well.

Quick subdomain setup for Windows Apache Localhost

Suppose you want to move a WordPress installation from one subdomain to another. You will need to know something about setting up subdomains, which is the topic of this section.

Setting up a subdomain on your locally hosted Apache webserver is not difficult. There’s plenty of material on the web explaining exactly how to accomplish this task… for specific and different combinations of Apache and Windows versions. As usual, none of these explanations fit my situation exactly. Most likely, none of them will fit yours either.

So here’s mine, which you can use as yet another resource. I’ll add some links I used for reference at the end of this section.

What you need to know:

  • How to use a plain old ASCII text editor. I use XEmacs. You can use Notepad or whatever you want. Just make sure you stay in plain old text.
  • Where your Apache webserver is installed. Mine is installed in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\. You may be using XAMPP, which is fine, these instructions will be adaptable to your situation.

    I’m going to refer to this location as APACHE_DIR for the rest of this article.

Here’s the steps for creating a subdomain:

  1. Create a subdirectory. For example, APACHE_DIR/htdocs/wptest. Creating a directory or folder should be easy for you. If this is confusing, leave a comment below.
  2. Edit Apache config to add the subdomain. This part can be a little tricky; you need to know something about how configuration in general works. We’ll take a detailed look at this in the next section.
  3. Edit the Windows /etc/hosts file. Again, could be a little tricky. There are a couple of ways to set this up, I’ll discuss in detail below.

Add subdomain to Apache httpd-vhosts.conf

As mentioned, everyone’s installation is going to be slightly different, so the best I can do is walk you through exactly what I did for my installation.

First, open APACHE_DIR/conf/httpd.conf. Find the lines that look like this:

460
461
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

You want to uncomment line 461, such that you are including conf/extra/httpd-vhosts.conf.

Now open APACHE_DIR/conf/extras/httpd-vhosts.conf. Make sure you’re serving from the correct port, in my case 8080:

17
18
19
# Use name-based virtual hosting.
#
NameVirtualHost *:8080

I have a couple of virtual examples in my conf file, which I’m going to comment out. Below those commented out sections, I added the following (Note: your line numbers will likely be different):

44
45
46
47
48
49
50
51
52
53
54
55
56
<VirtualHost *:8080>
    ServerAdmin admin@localhost
    DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/"
    ServerName localhost
    ErrorLog "logs/error.log"
 </VirtualHost>
 
<VirtualHost *:8080>
    ServerAdmin admin@localhost
    DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/wptest"
    ServerName wptest.localhost
    ErrorLog "logs/wptest-error.log"
 </VirtualHost>

For my configuration, I need to have my root directory set up explicitly as a VirtualHost. Otherwise, only the wptest subdomain works. Note that I added a specific error log for wptest. This is for my convenience, the webserver doesn’t care.

Use your own email address for ServerAdmin of course.

Adding to Windows etc/hosts

This is an easy step. Your hosts file should be located in or very near C:\Windows\System32\drivers\etc. Open this file in Notepad and add a single line:

127.0.0.1  wptest.localhost

Restart Apache.

Now, if you used “wptest” as your example as I did, you should be able to click the link http://wptest.localhost:8080/ and it will take you to your new subdomain.

Related links for localhost subdomains

These are the articles I used for reference, you should use them too:

  • Team Offshoot on Setting up localhost subdomains
  • Here’s Jared Hocutt’s article setting up subdomains on localhost.
  • After you have read the previous two links, and after you have your subdomain working, go read the official Apache VirtualHost documentation. There is more there than you probably need to know… but you should get familiar with what you don’t know.
  • Zaib Kaleem has an outstanding little article on moving a blog from a subdomain to your main domain. He points out to remember fixing the author’s URLs as well as to update the uploads URLs. There’s another article on the WordPress Codex that covers the same process from a slightly different perspective. The reader will find it easily using Google.
  • RajeshPG.com shows how to move WordPress from root to a subdirectory. This is a pretty good article, which I saved as a pdf for future reference. NOTE: I haven’t checked this article for accuracy, but the information is good enough that I could fix any typos, blunders or small errors easily.

How to move a blog using .htaccess magic

Suppose you have (as I do) a directory you want to rename from “wp28″ to “wordpress28,” perhaps as illustrative example for your blog. Or whatever. Bradley Charbonneau provides a distinctly telegraphic procedure for moving WordPress between subdirectories, which works fine for me, but bears a bit more in-depth examination for some readers.

So you’re moving a bunch of stuff around, say, like a WordPress blog… using .htaccess. Lot’s of wonderful tutorials on the web on rewriting URLs. For our example, the following .htaccess file handles the move:

1
2
3
RewriteEngine On
RewriteBase /wp28/
RewriteRule ^(.*)$ http://localhost:8080/wordpress28/$1 [L,R=301]

But no matter what you try… NOTHING works. Not even a little bit. Are you going crazy? Maybe, but there may be a simpler answer. Open up your httpd.conf file. Does it look like this:

114
115
116
117
118
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so

So, (my) line 116… you need to uncomment that if you want to use .htaccess for rewriting (which is what you want to do). Then make sure to restart Apache!

Did that do the trick? No? Ok, time to dig deeper.

Check the latest entries in logs/error.log. If you see an error similar to this:

[Mon Jul 20 12:38:19 2009] [error] [client 127.0.0.1] client denied by server configuration: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/wp28/.htaccess

you’re dead in the water.

But it’s easily fixable, if you know exactly what to do.

The operative phrases here are “client denied by server configuration” and “.htaccess.” Succinctly, you will need to allow Apache to use .htaccess to override default configuration that denies .htaccess usage. It’s not difficult, and there’s a couple of ways to do it. The first way is making the override global. That’s fast and easy, but not as secure. The second way is to override on a per-directory basis, which is what we’re going to do here:

1
2
3
4
5
6
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/wp28">
    Options -Indexes FollowSymLinks
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
</Directory>

Line 3 is the key, and the AuthConfig and FileInfo options will do what we want, namely, allow the redirect from wp28 to wordpress28. Add another one of these Directory modules for wordpress28 to enable permalinks for wordpress28 directory. Otherwise, you will be able to write the .htaccess file, but Apache won’t read it.

There’s even more…

If you’re run a cPanel-hosted site, you can change all the top-level redirects by doing a search and replace in the .htaccess for that site. Here’s the steps:

  1. Log in to cPanel, click on the “Redirects” link. You probably already know how to do this; if you’re changing redirects, you had to put them there in the first place right?
  2. Back up your current .htaccess file. I do it like this: .htaccess → .htaccess_todaysdate.
  3. Use your FTP program to download it for local editing, or edit it on the server if you feel brave. If you have a number of websites, you may already have flock of .htaccess files lurking, so editing on the server helps reduce the confusion.
  4. Do a search and replace to fix all the new URLs. Upload the new .htaccess and test everything out. Refresh your cPanel Redirects page to ensure everything works. That’s it, you’re done!

Giving WordPress it’s own subdirectory

Perhaps you would like to put all your files in a subdirectory, but have WordPress operate from the top level of the domain. For example, you want mycooldomain.com as your URL, but you want to keep all the files safely tucked away in mycooldomain.com/main1 (don’t ask).

This is so easy and common that the WordPress Codex has just the procedure for you: Giving WordPress Its Own Directory.

That’s great if you are just starting out.

But suppose you have a blog that’s been in operation at mycooldomain/main1 for a long time, with dozens of hundreds of posts and pages, and great search engine results. You need to do a little more work to capture all the results going from the old URL to the new. John Godley’s Redirection plugin is just the ticket.

The idea is to set up a new redirection using regular expressions. Using the directions on the Redirection home page, here’s what it looks like:

Setting up redirection regular expression

Setting up redirection regular expression

It’s not difficult, and using your localhost installation for testing is smart.

One last thing: If you already have a sitemap generator installed, such as Google XML Sitemap, make sure you update the location of the resulting sitemap. If you do not, it will attempt to write the sitemap into your old location, and may fail.

And, when you do this “for real” instead of on localhost…

Make sure you change your settings for Google Webmaster Tools!

You will want to ensure the new sitemap uploads and is valid, then you want to examine the details to ensure all the URLs are correct. If you have your redirections set up properly, you may want to leave the existing sitemap in place for a while, until the new one is indexed. Don’t forget about your RSS feeds, feedburner, and URLs you may have in any other places.

Themes, plugins and more!

Having a localhost installation makes it easy and safe to test new themes and plugins. Your new plugins can meddle with the database with impunity. If you crash it or corrupt the database, no problem, just reinstall or re-import a testing database.

With themes, you can go wild with CSS and formatting and nobody will ever see how terrible it looks.

Other advantages of running a localhost webserver:

  • It’s easy to dig into Apache configuration, and no-risk when you mess it up (and you will mess it up).
  • Learning to handle various HTTP issues such as 404 errors and 301 redirects gives you a lot of power on once you apply your newfound knowledge to your production server.
  • You can develop entire maintenance procedures and scripts locally, testing and debugging before deploying live.

So if you haven’t installed a local webserver, block out a couple of hours and jump in. It’s not difficult, and your knowledge will pay you back in the future. Even if you have no plans to be a “professional” web developer, the more knowledge you have the easier it will be to outsource exactly what you need… without getting ripped off by unscrupulous developers.

How To Really Publish A WordPress Blog Post

(Reading time: 12 – 20 minutes)

Update 12/8/2009: An ebook based on this article is now at 40+ pages. Please sign up for the newsletter for a substantial discount once the ebook is launched. Thanks, and enjoy… there’s over 2800 words in this article!


I’ve published over 150 250 300 500 blog posts.

What I’ve learned during this process is that for posts under a couple of thousands words in length, writing is only about half the process. There’s a whole ‘nother half which allows people and search engines to find you later. This other half is a fixed cost in your time, but that fixed cost can be driven down with experience. With longer posts, the fixed cost reduces the time percentage necessary to spend on supporting structure.

The following article lays out the entire anatomy of a blog post and the publishing process. It’s my entire process and thinking behind each blog post here on Website In A Weekend. The secret sauce. The reading time may be listed as something like 12-20 minutes, but if you’re new to the game, that’s absurd. There’s enough material in this article to keep you busy for a few days. Print it out while you can (this post won’t be up forever), mark it up with your highlighter, take notes, etc. You will find this material increasingly valuable as you learn more about how both WordPress and SEO work.

From the top down, in order of short term importance:

Article structure

  1. Title: one of the most critical elements of your blog post or page. It’s the first part of your writing the world at large will see. Most likely, it’s the ONLY part of your writing the vast majority of people will ever see.

    Titles are worth getting right. There is a whole series of articles here on Website In A Weekend just on titles. Start with “How A Fool Stunt Will Make Me A Star Blogger” and follow the links forward. Watch for a page collecting all the articles together once the series is finished.

  2. Permalinks & post slugs are really important. Fortunately, there is a lot of information available on the web covering both. The nutshell explanation: pull the key words out of your title, remove stop words such as “and,” “the,” “in,” etc., use what remains as the post slug. The slug sits at the end of the URL to form a permalink. You want to get this right the first time. Watch for an in-depth article on permalinks and slugs in the future.
  3. Categories function like book or chapter titles, collecting relevant material unified by a common, easy-to-understand theme. Categories help both readers and SEO results in these ways:

    1. Readers interested in closely related articles will find a category listing invaluable. Done right, each category can be like a book, with each blog post a chapter.
    2. Choosing category names which contain keywords reflecting the core idea in each post gives you more weight on search engine results. You should set your permalink structure to incorporate categories to exploit the SEO benefit of category names. For example, using /%category%/&postname%/ is a very popular technique.

    Make sure to read “Choose 3 to 7 Posting Categories to More Effectively Focus Your Writing” carefully for solid technique useful to create your categories.

    Also, don’t use more than one category for each post. Under some conditions, search engines may penalize posts filed under more than one category as duplicate content.

  4. Tags function much like an index functions in the back of a book. Tags help readers looking for occurrences of specific terms in a range of contexts, and help search engines by providing more relevant key words for each post. Use no more then 5-7 tags for each post.

SEO-specific structure

  1. SEO Title: Use the blog post title as a default. There may be benefits to using a different title, and you can change the title later as long as your permalink doesn’t change.
  2. SEO Descriptions can be written in as an informative summary or “abstract” of the post allowing people to get the result without reading, or as a teaser explaining benefit to the reader for taking the time to read. If you’re interested in having readers, learn to write compelling teasers.
  3. SEO Keywords: Keyword importance is a murky area in SEO. Everyone agrees you need at least some keywords to help get that extra few percent in search results, but in the end, it seems to be simply a few percent. It does seem clear that keyword stuffing is largely a waste of time at present: search engines may discount keyword stuffed pages as spammers and scammers.

Publishing

  1. Testing: If you don’t test all the links in your post before you publish, you deserve whatever you get. Sure, testing is boring. But do you really want the excitement of viewing dozens of 404s in your error logs… all because you put a trailing slash on a redirection that didn’t have one? I sure don’t. I’ll take a little boredom up front and save myself big pain later.

    And don’t assume anyone will let you know that you’re links are busted. Not even your friends… they’re busy working on their own projects! If you’re blogging for business, unless your friends are also your customers, you shouldn’t expect them to read your work either.

Promotion

  1. Active promotion consists of all your efforts reaching out to your audience. Such activities include writing really high quality blog posts, leaving comments on related blogs and forums, develop WordPress plugins, using social media to propogate links to articles.
  2. Passive promotion consists of ensuring article content and SEO structure work hand in hand to drive traffic and keep readers, monitoring blog readership statistics, monitoring HTTP 404 errors and keeping HTTP 301 redirects up to date, getting articles posted quickly to leverage longevity, and interacting with readers.

Advanced

  1. Graphics should be used to support a story, to reinforce the article’s topic, or set an emotional tone. All three if possible. For example, screenshots can be used to support a story about nearly anything computers, and will also reinforce the topic.
  2. Relationship of post to website structure or metastructure should be explicitly given when applicable. Article in series should be noted. Revise existing articles when a new article slots into a series.
  3. Internal backlinking allows you use previously published blog posts and pages to support material in the current page. Internal backlinking is easy: the articles are already written, just add a link. The key is to make link a natural part of the text. The link should not interrupt the reader so much as invite the reader to explore in more detail. This takes practice.
  4. Internal forward linking requires revisiting older published blog articles and updating them appropriately for new material. Such articles may link to each other, but that’s not required. You will see forward linking all over this article in the future. I’ll date the forward links to demonstrate how it works. The key to forward linking is anticipating where the forward link will be, and structure the current text to support the link once the link target article is written. Again, this takes practice. It’s helpful if you have a notion of your website’s meta-structure, or have a story line or story arc in place to work against.

    Back in the old days of the web, before blogs forced us into a timeline-driven publication frame, there was simply “linking” and web pages were kept up to date with editing as necessary to incorporate changes on the website. The notion that web pages were inviolate after “publication” would have struck me, and probably every other person on then internet before ca. 2000 as laughably ludicrous.

  5. Human element: story lines and arcs, narrative threads, plots and subplots. From a technical point of view, the human element is superfluous, a waste of bits. From a readership point of view, the more emotional content you can bring to any subject, the wider your audience will be.

    I’m currently reading The Zen of Fish, which takes a rather dry subject (raw fish, or rather, flavored rice), and adds in an enormous amount of human interest to weave a compelling tale. Did you know that “hydrolyzed vegetable protein” is a food industry “code name” for monosodium glutamate? Fascinating, right? If you read the story, the fascination would emerge.

    Weave an emotionally compelling story about yourself, someone else, or just make something up, it doesn’t really matter. Stay with me here on Website In A Weekend, and watch as I start weaving such elements into these articles. Your story line will have an added benefit of creating truly unique content!

Setting readers expectations

Setting reader’s expectations is critically important. Feel free to evolve the content, the look, the feel, but gradually, so your regular readers don’t get lost. New readers won’t know the difference.

  1. You have a set way of interacting with the world. Use it. Not everyone will like it, especially if you become successful. This is what Tim Ferris calls “voice.” You don’t have to be a great writer, but you must develop your writing “voice.” Voice is how you use not just facts and figures, but how you use mood, pace, tempo and tone to communicate with your readers.

    Developing your voice takes time and practice. Most writers, including myself, find one or models to copy for a period of time. Like trying on new shoes. You have to walk around in them for a bit to see if they fit your style, and don’t hurt your feet. If you’re familiar with copy writing, you will recognize my main influence in my copy. I won’t say who that is, but that influence will wane as write more copy and find my own voice.

  2. Article structure: in general, you want to make it as easy as possible for the reader, but no easier. Each level of difficulty will screen for a category of people. If you write for readers that are broke, you will attract broke readers. Likewise, if you write for readers that have money and know what they want… that’s the kind of reader you will attract.

    Long time readers here know I favor expository articles which are information-heavy, and are often list-based. I write short “snackables” occasionally, in-depth articles when the subject calls for it, but very few rants.

    Each of these types of writing styles has it’s own structure. You want to find your strongest style and master that structure as fast as possible.

    Corresponding to article type is style issues: when and how to use emphasis, headers and subheaders, sentence and paragraph length, and how to employ those elements to guide the reader in a constructive direction.

    A blog post is a funny beast in many ways. It shares with journalism the intent to entertain and inform, yet shares with advertising an intent to rapidly call a reader to some sort of action.

  3. Shingling, overlap between articles may be used intelligently, but not overused. The concept is to introduce an idea with a brief discussion in one article, which links to an extensive discussion in one or more following articles, which are then summarized from different angles and different contexts in yet another series of articles. Needless to say (I’m going to say it anyway), both perspective and wording should be different in each article. Long term, you want to find a point in common with your readers. Providing different perspectives will encourage this. Repeating the same words over and over will bore your reader, or worse, annoy them.

    Posting the same content under different titles and permalinks also results in both posts being penalized by search engines. It has to be this way, else search engine results quickly deteriorate into a single article per key word or words, propogated everywhere. The reason for this is embedded deep into human nature: a certain number of people treat everything as a zero sum game, and ruin it for everyone else.

    Demonstration being one of the most powerful methods of instruction, check out how various previously published articles are summarized in this article, and watch for extensive discussions on other topics in the future.

  4. Advertising: if you plan to advertise in the future, you probably ought to get started now so that your current readers get used to seeing ads, and your new readers will become instant prospects. Taking a blog with no ads, then saturating it with ads will be very jarring for existing readers. Start placing ads intelligently while your readership is small.
  5. Access restrictions, membership-based. One characteristic of value is scarcity. Something hard to get has more value then something easy to get. The most obvious example of this fact is what you’re reading right now. Because anyone can read this material, it has little value.

    Another characteristic of value is cost. People pay money for what they value. Simple, really. The more value someone perceives, the more money, time or work they are willing to invest.
    Despite the very high actual value of the information presented in this article, people that paid hundreds or thousands of dollars for the exact same information will value it far more than you will!

    For example, economists and bankers sneer at gold, but you never see any gold just laying around, and for all it’s barbaric nature, it’s remarkably difficult to find anyone willing to give you any gold. (Disclaimer: I have been known to trade gold. This post does not constitute financial advice!) Same with articles. Most people won’t read this article. They will see the 12-20 minutes reading time and pass. Or, they will star it or bookmark it, then delete it later. That’s what I do. But if I charged $19.95 for this article, attractively formatted as a whitepaper or small ebook, at least some of the people that paid for it would read it! Here’s a little experiment: first person that sends me an email with “$7.13″ in the subject, I’ll send you $7.13 via paypal. Just a little test for my benefit.

  6. Hoops, teasers: making the reader do some work increases the perceived value in the copy. Personally I believe it increases the actual value for the reader as well. No one learns passively. Learning requires action. If you want a reader to learn, and the reader wants to learn, help him or her take action.

    Well-written teasers in RSS feeds induce taking action. The reader has to click through to read more. Many blogs don’t show an entire post on the front page. All articles start with teaser text, requiring a reader to click through to read more. When the reader clicks through, he or she is demonstrating a willingness to take the next step. It’s your job as a writer to guide your readers appropriately.

  7. Hidden offers are a way to advertise your services or products—usually but not always—on a quid pro quo basis. I use hidden offers extensively on Website In A Weekend to acquire business. At the time of publication, I have had very few takers. As a complete unknown in a highly competitive business (WordPress consulting), this is expected. I also expect that once it “starts to rain,” it’s going to pour, and I’ll have to remove those offers from my articles, or increase the price.

    If you haven’t used hidden offers before, send me an email with the subject line “Help me with hidden offers” and I’ll work with you to embed an offer in one of your posts. Or email me with the offer and the price I used in this article and I’ll give you 30 minutes of free coaching on any article published on Website In A Weekend.

    By the way, just between you and I, the free coaching is valuable for YOU… because you could probably get the same result trying to explain your problem to a brick wall. If this makes no sense to you, say so in the comments and I’ll explain.

As your blog moves out into the long tail of search results, there is some indication to me that this order inverts with time. SEO and article structure become much less important than absolutely compelling content. You can see this by examining the content of the first page of Google SERPS for “hot terms.” You’ll find about 1/2 the top SERPS have absolutely no value to you. They exist because the site operator was able to game the search engine into delivering a page irrelevant to you, yet one that has either a sales pitch or is so loaded with ads that the minute click through rates justify the technique (to the website operator).

If you can get your material out there, and you’re in it for the long haul, your page views will certainly increase regardless of whatever idiotic search engine gaming happens to be the day’s rage.

If you’ve read this far, you won’t be surprised to find this article listed as premium content at some undisclosed time in the future. Or sold as a white paper or part of an ebook. In the meantime, enjoy!