If you like tinkering with things you will have inevitably run into the scenario where you had something which was working, albeit maybe no just quite how you wanted it. After looking through manuals and reading a bunch of documentation it’s time to play around with things that may seem a bit foreign or off the beaten path. What generally happens to me is that I’ll mess with something in an effort to make it better and then end up screwing up everything.
This is the second in the series of posts I’ll be making on how to backup your WordPress blog and then run it locally. The first post dealt with how to backup your site. This post will talk about how to setup an environment to run your site locally. The last post will cover how to restore your site locally.
Setting Up Your Local Hosting Environment
When you are running your site in “production” it runs using some hosting provider’s services to execute the code and send back the pages. WordPress needs to run under a web server that can process PHP. There are several requirements for WordPress. You can read about them here.
To get things running on your local machine you will need to mimic the same environment locally. Depending on what type of OS your machine has on it you’ll need to go on different routes to setup your environment.
If you are running a Linux distro it used to be a handful to get all the packages together. While I’m not going to cover the Linux setup here, the setup of a LAMP server has gotten much easier. LAMP stands for Linux, Apache2, MySQL, and PHP. I suggest heading over to Google and running a search for “LAMP setup”. Insert the name of your distro in the search to get specific help for your particular situation.
Since most of my readers are Windows users I’ll be covering a variation on the LAMP setup. Remove the ‘L’ from LAMP and insert a ‘W’ for Windows!
Windows + Apache 2 + MySQL + PHP = WAMP
WAMP is a complete software stack for hosting websites. Installing this stack allows you to run a local instance of the WordPress site on your machine. The best thing about the WAMP stack is that you’re not going to have to go out and download each of the components separately and configure them to work together. That job has already been done for you!
Head over to the WAMP site and download the version for your computer architecture, 32bit or 64bit.
Setting up WAMP is as simple as double-clicking the installer file. The installer will already have the latest versions of Apache2, MySQL, and PHP. The installer will auto-populate with a directory on the root of your drive. It is a good idea to use that directory name. Installing it on your C:\ drive isn’t necessary, however. The last step performed by the installer is that it configures some basic settings. It will ask if you want to change the default browser it launches and the default text editor. If you’re using Chrome or FireFox take the time to change the setting to point to your browser of choice. Do the same with the text editor.
Once the installer has completed with the installation and configuration you can find the root of your new web server in the www folder which was selected at the beginning of the installation process. If you’re using the 64bit version of WAMP the folder’s location should be something like C:\wamp64\www. This is where you’ll be placing the backup of your WordPress site.
When WAMP is running you’ll notice a little icon shaped like a ‘W’ in your tray. Clicking on it will give you a menu of actions to perform on the server.
Most of the advanced configuration and options are not something I’ll cover here. There are many other sites that cover them. For the purpose of getting your WordPress site running locally you don’t need to make any other changes.
Some Other Quick Points
Your MySQL setup will only have one user, root. The root user is setup with no password. This user has complete rights over the entire database server. In production you would never use this user or type of configuration. However, for you local site it is easy to just use this user for all of your sites since it makes setup easier. Just remember this when you’re wanting to move to another location to host your site.
In the www folder you can create a folder for a number of “sites”. For instance, I have a directory for my personal site, a copy of it for theme edits, and then a third for my RC club’s site. You access each site by typing http://localhost/<directory_name> into your browser’s address bar. Since this URL is different than what you would type in for your sites public site you can run into some configuration issues. In my next post I’ll explain how you can configure each site to work with these URLs.
Once you have your site backed up and a place to run it locally you are ready to restore your site. I’ll be covering this in the next post.