Browsed by
Month: April 2016

How to edit a WordPress site offline on your Windows desktop using WAMP

How to edit a WordPress site offline on your Windows desktop using WAMP

WordPress: How to edit your site offline on your Windows Desktop using WAMP

In my previous post I covered the installation of WordPress with WAMP. You might want to read that before continuing here! Now that I have wampserver and WordPress installed and running on my desktop it’s time to import my production site so I can make changes offline. Once again I have another gripe with the WordPress documentation – There isn’t enough detail on this topic. How to move your WordPress site to edit it offline should be discussed in the “Moving WordPress” section of their Codex. I tried reading the above section but it’s so generic it’s mostly unhelpful. With this post I aim to help anyone in a similar situation to me.

Backing up your online WordPress site

Your WordPress database contains every post, every comment and every link you have on your blog. If your database gets erased or corrupted, you stand to lose everything you have written. While I could go through the process of doing everything manually, I decided to make use of the various plugins available in WordPress. I started with “UpdraftPlus – Backup/Restore” but in order to make use of migrate and export options I needed to buy another plugin for that plugin – Yeah, not happening. Next up I decided to take a look at a plugin named “Backup Guard” which seems to work great so far.

First off I installed BackupGuard on the production site. After installation there is a new entry in the sidebar for “Backup Guard”. Clicking on the backup guard entry will bring you to the following GUI where you can complete a backup or import a previous backup. I performed a manual backup and you can see it completed successfully:

wordpress mage of backup guard

I connected to the production site via SFTP and transferred the backup to my local desktop. Swapping over to the offline instance of WordPress I tried to import the backup, however it told me the file was too large (67MB) but offered me an alternative:

wordpress mage of backup guard

If your file is larger than 2MB you can copy it inside the following folder and it will be automatically detected: C:\WAMP\www\wordpress\wp-content\uploads\backup-guard

Please note your directory may be different depending where you installed WordPress. So I did just that; Copied my sgbp file to the above folder and it appeared once I returned to the backup guard section again. Now I just needed to click the restore button and hope everything went to plan:

wordpress mage of backup guard

This process took approximately a minute or so and then I was brought back to the login prompt again. First I felt a little panicky because my credentials I setup in the previous installation were not being accepted. Then I realised my mistake; The credentials being requested were those of my live website rather than the offline instance – Silly me! After logging in all of my pages and posts were visible from the production website on my offline instance. The import was a success!

Much easier than I expected – Highly recommend Backup Guard!

How to install WordPress locally on your Windows desktop using WAMP

How to install WordPress locally on your Windows desktop using WAMP

WAMP Server: How we can use it to edit WordPress sites offline

Now that we have a fundamental understanding of how a WordPress theme functions, it’s time to start using WordPress.

To run WordPress on any machine there are a few requirements:
  • PHP version 5.6 or greater
  • MySQL version 5.6 or greater OR MariaDB version 10.0 or greater
  • ‘Web server software such as Apache

This may seem like an intimidating list of software to source and download one-by-one, but that won’t be necessary. This is where WAMP comes into play!

What is WAMP and why do I need it?

WampServer is a Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database. Alongside, PhpMyAdmin allows you to manage easily your databases. An all-in-one package which contains everything that WordPress requires so our lives had suddenly become much easier. There are other clients for Windows such as XAMPP with the biggest difference being that WAMP runs on Windows, XAMPP is multi-platform. Aside from that it’s a matter of personal preference. They both provide you with an Apache-MySQL-PHP environment that runs pretty much the same under both systems.

Installing wampserver on Windows

Before installing WordPress you will need to download and install wampserver on your Windows desktop. Double click on the downloaded file and just follow the instructions. Everything is automatic. The WampServer package is delivered with the latest releases of Apache, MySQL and PHP.

You will need to choose the installation directoy for WAMP – The recommendation being that you do not install to “Program Files” but instead install it in a folder in the root directory as there could potentially be some permissions issues. I installed it to C:WAMP which worked fine. At one point during the installation, WampServer will ask for the location of the default web browser and text editor. WampServer will automatically choose notepad.exe and Internet Explorer as the default options but these can be changed if needed.

Once the installation completes successfully you should see the ‘W’ icon in your notification area:

wamp server icon in notification area
If you don’t you will need to start wampserver by finding the entry in your start menu. On Windows 8 my entry looked like this:

wamp erserver icon in start menuCreating a database for WordPress to use

Before installing WordPress you will need to create a database that WordPress can use. To do this we will need to access one of the wampserver features named phpMyAdmin. Easiest method of accessing this is to left-click the wampserver icon and click on phpMyAdmin:

phpmyadmin entry in wamp server

This will open a new browser window to http://localhost/phpmyadmin with a login prompt (Or you can just go to this URL manually). The default credentials here are root with no password. When you log in you may notice the big warning at the bottom of the page stating “You are connected as ‘root’ with no password, which corresponds to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user ‘root’.” Sounds scary but this is not a problem as long as this is only a local installation.

Click on the databases tab at the top of the page which will give you a list of the current databases and allow you to create a new database. In the ‘Create database’ menu enter a name for your database. I called mine ‘wordpress’ for simplicity sake:

wordpress database in wamp phpmyadmin

Download and install WordPress on Windows

Don’t worry we’re almost there! Now it’s time to go and grab yourself a copy of WordPress from their website. This will download a .zip file which you will need to unzip. Once unzipped you will find a wordpress folder which you will need to move to C:\WAMP\www. So my directory structure looks like C:\WAMP\www\wordpress. As soon as the copy completes you should be able to access WordPress via your web browser via http://localhost/wordpress. If you rename the wordpress folder to mysite then you would access it via http://localhost/mysite. You should be prompted to choose your language for WordPress. WordPress will then inform you that it is going to create a wp-config file using the provided information in the following steps. If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php.

One the next page you will need to enter your database details. Here is what mine looks like:

Wordpress database information using wamp

If you recall in the earlier steps I created a database named wordpress and we logged in using the default credentials of root and no password. If this works you can proceed to the next steps with a very friendly message:

All right, sunshine! You’ve made it through this part of the installation. WordPress can now communicate with your database. 

Now we can proceed with actually installing WordPress!

On the next page it will ask you for:

  • A website title – What is the name of your website? I just named mine offline.
  • A username for logging in with
  • A password for the above username
  • An email address

If the installation succeeds you should then be brought to the login prompt where you will need to enter the username and password you just created.

What now?

Whatever you want! You now have a fully functional installation of WordPress which you can use testing and offline development. Have fun!!

If you want to learn more take a look at a few of my other WordPress posts:

WORDPRESS – THE THEME HIERARCHY

HOW TO EDIT A WORDPRESS SITE OFFLINE ON YOUR WINDOWS DESKTOP USING WAMP