WordPress in Windows: Part Two

Installing WordPress in Windows with WampServer

So, we’ve got WampServer installed on a Windows machine, verified that it’s working – no port conflicts – and we’re ready to forge ahead with installing WordPress. If you’ve just arrived from the Google, thanks to my search engine optimization (SEO) skills and/or SEO plugin, head here for Part the First of my modest WordPress in Windows tutorial. Otherwise, let us proceed to rock, in a computer nerd sort of way.

Step One: Setting up WordPress’ local MySQL Database

First thing’s first, and that’s setting up the database that WordPress will use. Launch WampServer if you don’t already have it running and left click on the system tray icon. In the resulting list of menu options, click on phpMyAdmin. If you’ve already used WordPress on a live Website – especially if you’ve ever migrated a WordPress site from one Web host to another – then you may be at least passingly familiar with this user interface for MySQL databases, phpMyAdmin.

phpMyAdmin: Danger Will Robinson! Root with no password!When you installed WampServer, you were asked if you wanted to create a user name and password for MySQL; if you did, I hope you wrote it down, as you’ll need this to log into phpMyAdmin. Otherwise the default is “root” with no password, and you won’t be asked to log in.

Now you may notice the warning that appears at the bottom of the initial page in phpMyAdmin (click on the image to the right to embiggen it and see). Unless other and nefarious persons use your computer with your Windows login credentials – your Mom, your brother, Skeletor, Jonathan James – or you plan on using your Web server to actually serve up Web sites to the Internet at large, I’m not sure it’s necessary to create a user name and password for phpMyAdmin.

On the other hand, phpMyAdmin isn’t terribly secure even with a user name and password; I wouldn’t use it to access a MySQL database for an online site from an unsecure connection – say a public Wi-Fi spot – unless I had to. Certainly wouldn’t want to make a habit out of it. But on your own computer that you’re not sharing? No worries, in my humble opinion. If someone physically steals my computer and managed to hack my Windows password, the last thing I’m going to worry about is that they get to see the new CSS I’m working on.

Time to Administrate that Local WordPress Install

phpMyAdmin: creating a new database is easy.So there’s phpMyAdmin; let’s get down to some database administration. We still need to create said database for our local version of WordPress. At the top of the page you’ll see a list of tabs; click on the one labeled “Databases.” At the bottom of this page you’ll see “create new database.” Enter the name of the database that WordPress will use.

You can name this whatever you want; if you just plan on creating one Website that uses WordPress locally, you can simply call it WordPress, if you want. If you plan on creating several sites locally – and with WampServer you can do this just as easily as one site – I would suggest naming it something relevant to the particular site — the domain name, perhaps — as all of your local sites will use MySQL databases which you can administer here through phpMyAdmin; you’ll want to be able to keep them sorted out.

In my example I’ve called my database Ralph, as you can see. But again, call it whatever you wish; call it database, or even Johnson. As for the other box, leave it to its default, Collation, and click create. And WAMP, there it is (and there’s that bad joke again). As you can see, Ralph is listed over in the left hand column of phpMyAdmin, along with the “information_schema” and “mysql” databases (these are databases used for MySQL’s internal administration; you don’t have to worry about them – at least as far as setting up and using local WordPress installations).

Okay, we’re done with phpMyAdmin for now. But keep the name of that database handy, if you think you can’t remember it, along with your phpMyAdmin/MySQL username and password, if you created one. We’ll need them for WordPress, which we’re finally ready to actually install.

Step Two: Unpack and Move WordPress Into Your Windows ‘hood

download WordPressSo, if you haven’t done so already, go to the WordPress Website and download the latest version of WordPress (3.1.1 as of this posting). Since we’re working on Windows you’ll want the *.zip file, of course.

Once that’s downloaded, unzip it and move all the files and folders to WampServer’s www directory (C:wampwww) or wherever you installed WampServer. Again, if you plan to make more than one local WordPress site, or think you might in the future, I’d suggest making separate directories – or folders (since we’re talking Windows, I suppose I should use Windows lingo) — in the www folder for each one. In my example here, I’m using a directory/folder called Ralph (C:wampwwwralph).

Installing WordPress in Windows: unpacked in the Ralph folder.So now my Ralph folder (C:wampwwwralph) looks like the picture at right, now that I’ve moved all of the WordPress files here.

Again, if you’ve used WordPress on an actual hosted Website, and you’ve used ftp to administer it or move files around, this should look familiar, and you can guess what we need to do next; in fact you could probably follow WordPress’ installation instructions from this point forward and be fine. But we’ll go through the steps just to be sure.

I should note here that when you unzip WordPress, all of the files and folders are themselves in a folder called WordPress; we want to move or unzip those files and folders inside the WordPress folder into our the Ralph folder, or whatever you call it.

Step Three: Configuring Our Local WordPress Install

Now we need to edit the wp-config.php in our WordPress directory; in this case that’s the Ralph folder. We would need to do this same step were we creating a WordPress site on a Web host out on the Internet, too. Literally what we’re doing is telling WordPress where the database is that it will use to keep track of all our site’s posts, pages, images, and whatnot.

And actually wp-config.php isn’t in our folder – yet – but wp-config-sample.php is (refer to the image above of the Ralph folder). Like WordPress’ own install instructions, I’ll suggest that you make a copy of this in the same folder and rename it wp-config.php; wp-config-sample.php will server as your backup. This way, if you make a hash of it, you can start from scratch. But don’t worry, this is pretty simple.

Configuring WordPress for a local installation in WindowsOpen the wp-config.php you just made in Notepad or Wordpad – don’t use Microsoft Word or OpenOffice or some other word processor, particularly one that uses xml, as both of these do. You’ll end up with a bunch of junk in your file that you don’t want.

Incidentally, the same goes for if you are writing a post in your word processor first and then copying and pasting into the text editor inside WordPress. If you look at the html editor you’ll see a bunch of unwanted code came along with the text, and will probably make your post or page look goofy.

If you plan on doing a lot of file editing – php, css, html, etc. – I can suggest Notepad++; it’s a great text editor that’s designed for working with code. Furthermore it’s got spell check and a bunch of other features; you could use it for everyday writing/word processing as well (plus it’s got tabs!). Here is the wp-config.php file opened in Notepad++; I’ve circled in red the part of the file we need to edit (see the image on the left).

To wit:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database_name_here’);

/** MySQL database username */
define(‘DB_USER’, ‘username_here’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

/** Database Charset to use in creating database tables. */
define(‘DB_CHARSET’, ‘utf8’);

/** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);

Unless you made changes or used options beyond what I’ve discussed here, the only thing you need to worry about is the MySQL database name, username and password (DB_NAME, DB_USER and DB_PASSWORD); the default settings for hostname, charset and collate type in our WampServer setup should be the same as what is listed here.

  • Where it says ‘database_name_here’ enter the name of the database we created earlier in phpMyAdmin; in my case, that’s ‘ralph’. Make sure you keep the single quotes.
  • If you didn’t assign yourself a user name when you set up your MySQL database with phpMyAdmin, then where it says ‘username’ (in between the single quotes) type root, as in ‘root’. Again, be sure to keep the single quotes.
  • If you didn’t assign yourself a password then you can just delete password_here from between the single quotes – but leave the single quotes in place, with nothing in between them.

So in our example those three lines should look like:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘ralph’);

/** MySQL database username */
define(‘DB_USER’, ‘root’);

/** MySQL database password */
define(‘DB_PASSWORD’, ”);

Save these changes to wp-config.php, and close your text editor.

Step Four: Login to Your Local WordPress Install,
See if You Done Good

Yay! We installed everything right, and WordPress is running locally in Windows.Now we’re ready to log into our local WordPress installation. Open your Web browser and go to http://localhost/whatever-I-named-my-WordPress-folder/. In my case, that’s localhost/ralph/. If we did everything right, then we should see this, the initial installation screen for WordPress (on the right).

If you see this screen, congratulations; WordPress is installed and running locally on your desktop or laptop. From this point things are pretty straightforward – provided you remembered to enable the Apache rewrite_module.

If you’re thinking “what?” then check back at the end of the first part of this local WordPress installation tutorial. I’ll stress this in caps, even: ENABLING THE APACHE REWRITE_MODULE IS IMPORTANT! If this module isn’t enabled you may be able to see WordPress – if you are copying over an existing installation you can even navigate to your local site’s homepage and WordPress admin page, but if you try and navigate to any other pages, you’ll get 404 file-not-found errors.

As for the rest of the WordPress install, it’s up to you if you want to use a username and password for your WordPress admin login – well sort of. It used to be that way. Again, unless someone else has access to your computer and you share login credentials/user accounts for Windows, there’s not much worry. Certainly, if this were the case, I would password protect my WordPress admin login, just as I would for a Web hosted installation. But for my own computer, I don’t bother, to be honest.

However, the latest versions of WordPress now create a random password for you, if you leave the password sections blank – hence the “sort of/used to.” You can change this to something else later on, but you can’t leave the password blank, so it’s easiest to just set up an easy to remember password here at the initial install screen. Myself, for my local installs I usually stick with admin/admin or root/admin or some such combination of user/password that’s easy to remember.

You can uncheck the “Allow my site to appear in search engines” box, but unless you’ve configured your local server to be public in your WampServer setup and enabled external access in your firewall – and of course you’re using a firewall, because it’s Wind’oh!s – there’s not much worry. I suppose if you are running a public Web server from your home machine, some search engine spider could crawl your IP address and find your local development site.

So go ahead and name your site – you can change this later on in WordPress, of course – and enter your email address. WordPress will insist on this, so you’ll need to enter it. You can actually set up the mail function later on, if you wish – not sure I see the point for a local installation, but again, it’s up to you.

At this point, if we go to localhost/ralph (http://localhost/ralph) we see the default WordPress theme and the default “first post” and comment. If you navigate to localhost/ralph/wp-admin you can login into WordPress just like you would if you had installed it on an remotely-hosted Website.

That’s pretty much it. From this point you can begin experimenting with themes, plugins, CSS, page layouts, widgets, sidebars and so on and so forth. Or if you want to add content so that when you do put your live site up on your Web host, you have a bunch of content ready for your site visitors’ perusal, you can.

Pretty cool, huh?

Wait, what? How do you migrate a local site to your live site online, once you finish tinkering with it, you ask? I’ll save that for another post, but it should be pretty straightforward if you’ve gotten this far. But here’s a quick and dirty synopsis if you can’t wait and suddenly forgot how to use a search engine.

Uploading Your Local WordPress Site to Your Web Host

  • Export your database (as SQL) from phpMyAdmin (compress it via zip or tar to be on the safe side; default MySQL installs have a limit of how big a database it can import). As a backup method, also use WordPress’ export function, which exports all your relevant data in a single xml file.
  • Import your database into your MySQL installation on your Web host (you can probably do this from your host’s cPanel or something similar, or from phpMyAdmin. If you have problems here – different versions of MySQL or phpMyAdmin can be fussy about importing databases from one another – just create a new database with the same name; you can import that WordPress xml file later.
  • Upload your WordPress files (via ftp/sftp, cPanel, or whatever file manager your Web host provides).
  • Configure your wp-config file accordingly (database name, user name, password – you should definitely be passwording your online installation, of course; these can be different from what you used on your local machine; you don’t have to use the same ones).
  • Navigate in a browser to wherever your “index” page would be for your hosted site; if everything went well you will probably see a page telling you that WordPress needs to update its database and asking you to click “OK;” then it should take you to the admin login.

If you’re using a fresh install of WordPress, you’ll need to manually configure any plugins you use with your site; you’ll also won’t be asked to update the database. At this point you an also import your old WordPress site at this point by importing the xml file you exported on your old or local installation.

You’ll also likely need to fix/update your WordPress permalinks, depending on how you have your local installation of WordPress installed. For example, locally my site’s home/index page (index.php) is at http://localhost/ralph; if I had a page created in WordPress called Photos it would be at localhost/ralph/photos. On my Web host, assuming I install WordPress to my assigned root directory, my site would be at simply http://ralph (or whatever my domain name is); the Photos page would be at ralph/photos. Any internal links to the Photos page would need to be fixed, as they would still be pointing at localhost/ralph/photos (if I had installed locally to my root folder in WampServer, C:wampwww, then my links to Photos would be fine, assuming my domain name/URL I’m using on my Webhost is http://ralph).

There are several different plugins you can choose from to update your links automatically – the one’s I’ve used have worked fine, and you only have to run them once. Of course, if your site is fairly simple, you can do it manually from within WordPress for your various pages, too.

Well, that was  little longer than I intended — but I’ll address this topic later in a more in-depth post.

 

One thought on “WordPress in Windows: Part Two”

Leave a Reply

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