In my last post on WordPress we looked at using it as a viable option for non-blogging web sites (i.e. a full CMS), some of the benefits and alternatives. If you're convinced that WordPress is the right platform for you then read on...
In this post, using WordPress.org, I'll be running you through all the steps you need to get you set up with a local server environment running with a copy of WordPress so you can play about with the code without worrying about who's looking at it or breaking it.
Before we go any further, let's get one thing straight - what's the difference between WordPress.org and WordPress.com. WordPress.com is straight up for quick WordPress installations, hosted by WordPress themselves. This is great for non-developers who simply want a blog with the default features and don't want to pay for, or get involved in managing the hosting side of things. The downside of this type of WordPress installation though is that you cannot modify the code, and the themes and plugins you can use are limited.
WordPress.org on the other hand is where the developers get involved. The WordPress 'platform' can be downloaded as a software package to install and build on. This site features all the documentation, themes and plugins that you can customise on an installation of WordPress that you would host yourself.
One last thing before we dive in then, what's a local environment? A local environment is the concept of turning your personal computer (i.e. local) into a server so that it can behave in a way that your web hosting server would. This allows you to setup your own local domains and web sites so that you can test your code before you put it into a live environment. What does this mean practically? You can have mygreatsite.dev with a copy of your code for building on and testing, and then when it's ready you can upload the site to yourgreatsite.com so that everyone can see it. If you need to make any future changes to the site, you can test them on yourgreatsite.dev before you push them up to live.
If you're only interested in the steps to setup WordPress then feel free to jump ahead.
Without further ado...
So first we need to configure your computer as a server. Throughout this tutorial I will be giving steps predominantly orientated towards PC users, but I'll try to provide additional resources for mac users where possible.
Honestly, there is very little difference between WAMP and XAMPP, I use one at work and the other on my home machines and both achieve the same results. Generally I believe WAMPSERVER to by more widely used and user-friendly so I'd recommend this choice if you're unsure. Have a read up if you want to, choose an option and download their software, default configuration options are fine.
So now you've got a local server, you'll need a local domain that you'll be accessing WordPress on. For my local environments I always use '.dev' so I know I'm working locally, you don't want to be using '.co.uk' or '.com' like the live versions otherwise it would always override the real version. Follow these steps to setup 'wordpress.dev' locally (though you can call this whatever suits you best):
To test your configuration is working, create the folder 'wordpress' inside 'htdocs' or 'www', create another folder inside this called 'public', and finally place an index.html file in your public directory for the site (with a 'hello world' in it). Browse to wordpress.dev in your browser and you should see this appear.
Congratulations, you've set up a local server!
WordPress does most of the default database configuration for you, but you will at least need to set the actual database up first. Follow these steps:
Well that was easy.
Next we need a copy of WordPress, you can download this from WordPress.org.
Extract the downloaded files into your public folder we created earlier.
Inside the public folder you will now find a file called wp-config.php, this contains all the core site settings. Open it up and update the following settings for the database you set up earlier, if you're using the root user then you should only need to change the DB_NAME for now (note this would be different for a live environment as you would never use the 'root' user in production):
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
Finally, go to wordpress.dev in your browser and follow the default installation steps to complete the setup process.
For more configuration options check out the WordPress codex installation guide.
Now you've got your own local copy of WordPress up and running you can go ahead and play with the code as much as you want without worrying about breaking anything. In upcoming posts we'll be looking at the core WordPress concepts and how to create your own 'child' theme based off the default 'TwentyThirteen'.