Tuesday 7 February 2012

Wordpress - starting from scratch

Why Wordpress?

Today I decided to download and play with Wordpress. I've used it in the past to blog about my travels, with a fairly basic layout and not much functionality in terms of widgets and social media connections. As I've been doing a lot of development in Joomla! lately, I decided to work my magic on a local Wordpress installation - to change the theme at the very least.


Download Wordpress

The free Wordpress site wordpress.org lets you create a new Wordpress blog really quickly, with free hosting and a choice of themes (colours, fonts and images that spice up your blog). However, I want to change the theme and develop my own from a Photoshop image that I'll cut up and use in CSS.

To download Wordpress go to the download page and download the right one for your computer. The zip file for Windows and the tar.gz otherwise (mac or other unix based systems like RedHat or Ubuntu etc). Keep it in the downloads folder for now.


Set-up XAMPP

Wordpress needs a few things to run. If you have hosting, they'll probably support Wordpress. They may even have it all installed and ready to go for you. However, as I'm working on my theme from home, I need everything on my laptop. Wordpress needs the following things to work:

  • A web server that supports PHP
  • A web server that can re-write URLs
  • A MySQL database

Apache is the most common web server used as it supports the first two items. A MySQL database is a free database that holds all the data for your blog. You can download it all separately from each of the websites, but the best method is to download a pre-packaged installation that all works together nicely from XAMPP. Download the correct one for your platform and put in the C:\ directory. To start it just double-click on C:\xampp\xampp-control.exe

Then start MySQL and Apache by pressing the Start buttons next to them.




Un-zip Wordpress

Now copy your Wordpress zip file you downloaded into the C:\xampp directory and un-zip it.
As I have lots of Joomla! projects on the go, I let it expand into C:\xampp\htdocs\wordpress, but you can expand it straight under htdocs if you like to give a URL of http://localhost/yourproject, instead of my http://localhost/wordpress/myproject.

To check its all working, open the browser and type localhost into the address bar. I get the following list of folders:













You wouldn't get anything if you hadn't started Apache. You can see that we are using Apache and that it supports PHP and a lot of other things. You can also see that we are using Port 80. As an aside, Skype also uses Port 80 and so these two don't get along together. Usually your development server loses out, so if you have problems with XAMPP, check that Skype is off as well as turning it all off and on again :)


Set-up Database

Wordpress uses the MySQL database. If you have hosting and they support Wordpress, you'll also be able to set-up a database too. Each host's way of doing this is different, but log in and create a new database for your Wordpress installation. Or get the details of one that has been set up for you. You'll need this to put your local installation on the web. But for now we're working locally.

To view the local database we'll be using phpMyAdmin. We could use the command line to talk to our database, but why bother when you can see it prettily rendered in a web browser. phpMyAdmin is a free tool written in PHP (hence the PHP bit) that allows you to Administer your MySQL website. You'll find it bundled in XAMPP so just go to http://localhost/phpmyadmin/ in your web browser.



The first thing to do is to create a new database. Let's call it wordpress. Now we need a user to access this database. Go to the Privileges tab and create a new user with all the privileges called wordpress_user with a password of wordpress.



You don't need to create a new database for every installation of Wordpress, you can prefix the tables and have many installations using the same database, but I'm going to keep it simple for now.


Configure Wordpress

All this database set-up has been done because the first thing the Wordpress installation is going to ask for is database connection details.

In your web browser, type http://localhost/wordpress/wp-admin/install.php into the address field. You will get the following message:



As we're working locally, lets follow the web interface and press the Create a Configuration File button. We get this next screen:



We already have these set up from the previous step, so Let's go!



Result!



Now it's time to fill in some site-specific information:





"adminWordpress" isn't really a Strong password lol




Awesome! It didn't even take 5 minutes. Let's Log In.





Success! :)