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.

 

WordPress in Windows

WAMP it into Shape: Installing WordPress Locally Under Windows

You can easily install WordPress locally on WindowsI’ve been working with WordPress in one way or another – personally and professionally – for several years now, but it’s only been in the past year or so that I began to feel the need to have a local installation. For the non-nerd reading this, that means having a Web server and database installed along with WordPress on my own computers – desktop and laptop – so I can work on and develop sites offline.

Whether creating a new WordPress Website or working on an existing one – say changing or modifying a theme, or trying out new plugins/developing your own – or developing some other sort of site or Web app that requires something more than simple html, it’s nice to be able to work locally, offline. This is especially true if you have an existing site that you don’t want to risk breaking. Of course you can create a subdomain of a live site for development and experimental purposes, but I find it’s easy to just do it locally then upload the files when whatever it is I’m working on is ready for the public eye.

Certainly this idea is nothing new to Web developers and programmers, and for the technically savvy, it’s rather simple to setup a local Web server and do this. But then there are many people blogging nowadays or otherwise using WordPress as a content management system for their or their employer’s Websites who probably still think of Native Americans if they here the word Apache, as opposed to Web server software. It wasn’t too long ago that I would have fallen into this latter category.

Thus it is with these people in mind – as much as for my own edification and future reference – that I take pen to paper (er, rather, keyboard to LibreOffice Writer) to help elucidate how to go about setting up and installing WordPress locally on your own computer. I’ve done this on both Windows XP and Windows 7, as well as Ubuntu. When I originally set about setting up WordPress locally, I found a lot of helpful information on various blogs, so you could say this is just my effort to pay it forward and add to the pool of DIY knowledge of Web nerdom and/or geekery out there on Teh Internets.

With that said, bear in mind that this is what works for me on my particularly hardware and software; it may or may not work for you, for a variety of reasons – no, this is not rocket science, but this is computer science. As such it can get wee bit complex.

WAMP! There It Is!

To work with WordPress locally, you need to set up a Web server on your computer, one that can accommodate MySQL database management and the PHP scripting language; these are two basic components of WordPress; this is what’s under the hood. Typically you’ll want to use Apache for your Web server; this free and open-source server software is pretty ubiquitous these days, and there are versions available for just about every operating system (OS) there is. The odds are your own Web host uses some version of it, and it gets along just fine with the software that WordPress uses.

Of course if you’ve used WordPress before, you’re probably familiar with some of the PHP files it incorporates, and have probably used phpMyAdmin, a Web-based user interface for MySQL.

WampServer 2: Apache, MySQL and PHP on WindowsYou could install Apache – or some other Web server software – MySQL and PHP individually on your Windows machine. Or you can opt for easy mode, and install it in one fell swoop, with WampServer 2. WAMP is an acronym for Windows, Apache, MySQL and PHP (or Perl or Python) – W-A-M-P. Because we can’t talk tech without an acronym.

But it’s no joke: WampServer 2 makes getting all this up and running on your Windows box almost ridiculously easy. There are other WAMP packages out there besides WampServer 2 (previously WAMP5) – XAMP is another one, for instance. Wikipedia has a nice comparison of the various WAMP packages out there; there are plenty of options. But WampServer is what I use, as I’ve had almost no trouble at all with it under both XP and Win7, and can vouch that it will work just fine with WordPress. A further bonus: it’s open-source software and free to use – although I’m sure it’s author, Romain Bourdon, would appreciate a donation via PayPal. Vive le Français!

You can learn more about WampServer — how to install it and how it works with Apache, PHP and MySQL — and there you can also download both 32-bit and 64-bit versions, depending on what version of Windows you are using. Currently I’m using the 64-bit version of WampServer 2.1 on Windows 7 Professional; I’ve also used WampServer 2.0 on my ancient XP laptop (which is now an Ubuntu laptop).

Step One: WampServer is Easy Mode for a Local WAMP Install

So download it, install it, and run it just like you would any other software package. You may notice during the installation, however, that WampServer’s default installation process doesn’t install to Windows’ usual Program Files directory. Left to its own devices, WampServer creates a root directory under Windows (C:wamp), where you’ll find a www subdirectory (think of it as your local Word Wide Web), among others (C:wampwww). It is here where your local WordPress install will reside. You can of course install WampServer and the related files and sub-directories/folders wherever you wish, but to keep things simple later on, I’d suggest sticking with this default setup.

WampServer is online in Windows -- as indicated by the system tray icon.When WampServer is running, you’ll see a little icon in the Windows system tray. In 2.1 on Win7, the tray icon is a stylized W; on 2.0 under XP it was a little analog dial. With this latest version it’s easy to tell if it’s offline or online; online it’s green; offline it’s red – green go, red stop. Simple enough, yeah?

An important thing to note: WampServer uses port 80 – or rather, Apache does — and this can sometimes conflict with other apps that also use this port, namely Skype. You can assign different ports for your various software – just make sure the ports you assign are not used by other apps. But if you want to keep it simple, just open WampServer first before you open Skype; Skype automatically chooses another port if port 80 is taken, and you can then run both Skype and WampServer happily at the same time.

If you launch WampServer and it can’t seem to get online within a few moments, it is probably some sort of port conflict; if you have Skype running it almost certainly is (speaking from personal experience here). Also note that WampServer must be online for you to access it locally – which you can do even if your computer itself is offline, i.e, not connected to the Internet.

You shouldn’t have any problems with Windows Firewall running WampServer; it automatically sets up an exception for the Apache server for local use during installation. Again, if you have trouble with it getting online, I would look for some sort of port conflict first. Of course if you run a third-party firewall, you may need to manually enable an exception for WampServer – or if you want to actually use the Web server for consumption out there on the Intertubes.

Step 2:
Verify Your Local Web Server is Up and Running — and Writable!

the WampServer 2 menu in WindowsSo, if you have WampServer up and running and online, we’re just about ready to start installing WordPress; there’s just one more thing to do and that’s make sure everything is copacetic with our install. Left click on the WampServer tray icon; you’ll be presented with a menu list – here you can start or stop WampServer, make changes to your Apache, MySQL and PHP configurations and navigate to your local directory where your Websites will reside.

In fact, if you click on the first option, “localhost,” you should see an information page open in your Web browser that provides details on your WampServer installation: the versions of Apache, MySQL and PHP it is using, configuration tools, links to the local directory and subdirectories, and so forth. This page you see is actually just a PHP file in your root directory (C:www) that WampServer creates during its installation. If you enter http://localhost/index.php in your browser when WampServer is running, you’ll see the same page; you can see an example from a screen cap at the bottom of this post.

Of course if you can see this page, then everything is hunky dory with WampServer. There’s just one more thing to do, but this is important, particularly for Windows 7 and Vista users. We need to make sure that WordPress has the rights to create, edit, and delete files in our www folder/directory. To do this:

  • Finding the Apache rewrite_module in WampServer 2right click on the WampServer tray icon to get the WampServer menu (pictured above)
  • right click on the Apache item to expand the submenu
  • right click on the Apache Modules item to expand that submenu (pictured to the right)

Now you should see a long list of modules that can be enabled in WampServer’s Apache configuration; you’ll probably have to scroll down to see the one we need to enable, the “rewrite_module.” Click it to enable it; if it has a check mark next to it – as in the image you see here – it’s enabled and you’re good to go.

Okay, we’re done tinkering with WampServer and ready to get rolling on that WordPress install. But this post is long enough; go here for the next step in this tutorial for installing WordPress under Windows.

The WampServer 2 landing page - index.php. If you can navigate to this, everything installed and is running correctly.