Home

Using WAMP to Set Up a Development Environment For WordPress

The web is always changing and if you have clients like mine, you may find yourself with a long to do list of website tweaks and updates.  The good news is WordPress, when combined with Wamp Server, makes it really easy to set up a development environment to safely make changes (and fix errors from those changes) without affecting the live site.

WordPress Logo

However, in my early days as a developer I found myself making these changes to a live site.  I was lost in the matrix; I didn’t understand the difference between local and live environments and more importantly, how to quickly transition between the two.

I turned beautiful websites into a giant construction project; most of the building intact, but with pieces of brick scattered here and there.  If a user were to go to the site during my renovations, they would be able to see something new every time they reloaded the page.  As I began experimenting with Wamp Server, I started to realize that I could work on websites locally and launch the changes all at once.  But I would find myself making the process too complicated, copying an entire site to my local drive, reconfiguring the files to run locally, and then re-uploading the entire site to the web.  It just took too long.

Some of you may ask, what the heck were you thinking?  Hopefully some will be in the same boat I was in and will be looking for a answer on how to get out.  The simple truth is I was new and didn’t have a lot of experience under my belt; my understanding of how to use WordPress as a content management system was very limited; and even with the plethora of how-to resources available for WordPress, I found it difficult putting all of the pieces together.

As with any business, a key to profitability is developing good processes that save you time and money.  The answer?  Create a local development environment that you can easily interchange WordPress themes with.

1. Download, install and turn on Wamp Server.

WampServer LogoWAMP stands for Windows, Apache, MySQL, and PHP.  The last three are specific to servers and don’t come standard on your computer because most people don’t need to run their computers as servers.  A WAMP environment describes the development environment and is essentially a live server, just on your local machine.

Wamp Server is like WAMP for dummies.  In the past you had to download, install, and configure Apache, MySQL, and PHP all separately.  For guys like me, I had no idea how to do this.  Fortunately, the guys who developed Wamp Server have made it incredibly simple to download and setup.

Once you’re done, you should see a “WampServer” folder under your programs.  Simply click “start WampServer”.

2. Setup your database.

Hopefully you already have some experience with WordPress.  As you know WordPress needs a database to interact with so let’s set one up on our machine.

Type “localhost” (no quotes) into your browser.  Under tools, click “phpmyadmin”.  From that screen you can create a new database.  You can name it whatever you want, but for simplicity I would just name it “wordpress”.

3. Download the latest copy of WordPress.

If you installed Wamp correctly, you should see a “wamp” folder in your C: drive.  Inside this folder you will see a “www” folder.  Anything in this folder will be read like a website.  Navigate to this folder and copy WordPress into it.  Make sure you’re you have unzipped the WordPress folder.

4. Setup Your WordPress Environment.

Look in the WordPress folder and open up wp-config-sample.php with any text editor.  Set DB_NAME to “wordpress” or whatever you named your database.  Set DB_USER to “root”.  Set DB_HOST to “localhost”.

 

  1. /** MySQL settings-You can get this info from your web host */
  2. /** The name of the database for WordPress */
  3. define('DB_NAME', 'wordpress');
  4. /** MySQL database username */
  5. define('DB_USER', 'root');
  6. /** MySQL database password */
  7. define('DB_PASSWORD', '');
  8. /** MySQL hostname */
  9. define('DB_HOST', 'localhost');
  10. /** Database Charset to use in creating database tables. */
  11. define('DB_CHARSET', 'utf8');
  12. /*The Database Collate type. Don't change this if in doubt.*/
  13. define('DB_COLLATE', '');

********  Save the file as “wp-config.php”  ********

5. Setup up your local WordPress site.

Type “localhost” into your browser and under your projects, you should see a “wordpress” folder.  Click it and it will take you to the setup page for wordpress.  After you fill everything out, you will now have a local wordpress environment to work with.

Optional Steps

Here are some optional steps that I have taken to make it easier to operate in my development environment.

1. Download the latest copy of Aptana Studio.Aptana Logo

This step isn’t necessary if you are already fond of a specific editor, but Aptana is my preferred editor to use when working on development projects.

2. Create a WordPress web project

In Aptana you can choose to create a new web project.  I created a “WordPress” project and have it linked to my “wordpress” folder in C:\wamp\www.

*To link the folder, un-check “use default location” in the web project wizard and browse to find your “www/wordpress” folder.

Now what?

Now you can download any themes that you want to work on directly into C:\wamp\www\wordpress\wp-content\themes.  Edit them locally and view your changes from “localhost/wordpress” in your browser.  When you’re done editing the theme, simply re-upload it to your live version of WordPress.

Now if I have a client wants changes done to their site, I download their theme folder into my local theme folder, open up WordPress from localhost and activate the theme.  Depending on what changes need to be made, I will either use dummy posts or actually export and import some posts from their live site to work with.  *Note:  You may have to use the WordPress Importer Plugin to do this.

*Depending on how extensive your changes are, you may also want to create a new theme instead of editing the existing theme. This allows you to easily revert back to the original theme in case you find any major issues with the changes you make.   Just open your style sheet and change the name of the theme.  You just never know what will happen when you go live.  Better to be safe then sorry.

My rule of thumb:

  • HTML or CSS changes (anything that can be quickly undone) = update existing theme
  • Javascript or PHP (anything that involves a script and can mess up the functionality of the site) = make a new theme

Additional Notes:

If you are looking to change your permalink structure in WordPress, which I always do, then you’ll probably need to enable mod-rewrite.

Look for the Wamp Server icon in your task bar.  Navigate to apache, apache modules, then click rewrite_module.

If you have any issues related to this you may be able to find your answer here:

Other Resources:

  • Canadian Tech Online has a great YouTube video showing this process

10 thoughts on “Using WAMP to Set Up a Development Environment For WordPress

  1. Your post helped me a lot! However, I still have a couple of questions that hopefully you’d be able to answer.

    As Jasmine mentioned, I’m locally developing multiple WordPress sites at the same time (different theme, page content, etc.), but I’m fairly new to the WP world, therefore I’m using Bitnami Modules (for its easiness) to install WP in my localhost.
    That said, how would you point the Bitnami installation to your specified site folder?

    Also, since I’m working in various sites, I was wondering whether there would be a way of sharing a WP install instead of duplicating multiple new WP installs? My goal here is to save some space on my PC.

    Keep in mind though, that I will be migrating these sites to separate WP install subdomains afterwards. Separate databases are preferred.

    I’d appreciate your advice!

    Thanks a lot…

    NB.: FYI, I’m working on Linux Mint with XAMPP and latest WordPress version.

    • I haven’t worked with Bitnami before, but after signing up and taking a look around it looks like they set you up with a complete wordpress stack including apache and mysql. I’m not sure if that would work with multiple wordpress installs.

      WordPress Multisite may be a good solution for you to avoid downloading wordpress core files for every site you manage. I haven’t used it yet, but plan on doing so in the future. From what I understand, it allows you to use one set of WP core files to run multiple WP sites.

      Just a few tips on migrating WP to live subdomains:

      • Always, always work in the theme folder. Never modify core WP files or scripts.
      • Use TGA Plugin Activation to manage your plugins. This makes deployment and version control so much easier. I use Git as my version control system and I only track my theme folder. Once uploaded to the live site, TGA automatically installs my plugins for me.
      • Use WordPress’ export feature instead of exporting your database. This isn’t always the best option, but most times it works very well for my needs. It avoids me having to login to my local database or server database.

      I hope some of those help!

      • Thanks so much for your quick reply, you’re far more efficient than most related blogs out there. And I will definitely keep your suggestions in mind when I’ll be migrating sites.

        As for the Multisite option, I tried to install it but I incurred in some issues and couldn’t make it work. Also I found out that this feature creates only one database for all sites and I would require separate databases for each site. And last but not least, I came across this post:

        “Using multisite to develop then export to a single install is a bad idea. For one multisite behaves different than a single install and you want your dev to be as close to the production as possible. It’s also a pain to manually export the right db tables then import them into a new database.
        For developing locally I only use 2 or three WP installs. You’re mainly working on theme files so just create a new theme for each project and you can even use one dev database and change the table prefix in wp-config.php so so you don’t have to create a new database each time.”

        This sounded to me kind of your way of working -minus the extra WP core files- and I think this may be something that may work for my scenario, but I just don’t know exactly how to achieve it.

        Perhaps you could elaborate on it to help me understand it?

        Thanks again for your advice!!!

        • Thanks for the feedback on the Multisite option. That’s good information to know. Basically what this guy is doing is setting up 2 or 3 WP sites on his own computer. That’s his development environment. When he’s building a new WP theme, he builds it in one of the sites. For example, he may have localhost/wordpress, localhost/wordpress2 and localhost/wordpress3 on his computer. Let’s say he has someone ask him to build a theme for them so he starts working on it in localhost/wordpress. Then, maybe he finds some bugs in another theme he built (we’ll call it Bravo Theme) so he downloads the theme folder into localhost/wordpress2 and works on it in there. When he built the Bravo Theme, he used a table prefix of “bravo_”, so he can change the table prefix in wp-config.php to “bravo_” and then WP will read from all of the tables that start with “bravo_” in his database. That way, he can be working on two WP sites at the same time.

          He still has extra core files (2 or 3 WP Installs), just not one for every site and he uses one database, instead of 2 or 3 (one for each install) by changing the table prefix in wp-config.php. This is the file that is created when you run the WP install. Normally WP defaults the table prefix to “wp_”. If you look in a typical WP database, you would see wp_posts, wp_terms, wp_postmeta, etc. In his database, there would be wp_posts, bravo_posts, alpha_posts, etc. By changing the prefix, he can have as many tables as he wants in the database. His method involves 3 WP installs, 1 database and unlimited themes with unlimited matching table prefixes. Hope that helps!

  2. Thanks for the tutorial. It’s clearer than most others that I’ve read describing this process.

    How would you proceed if you were to have multiple WP sites under development at the same time? Would it just be a matter of naming each database after the site’s domain name, and creating the folders under the www folder with the same names (instead of wordpress for both)?

    • Thanks for the feedback Jasmine. What you described is similar to my approach when it comes to developing multiple WP sites at the same time.

      Let’s say you’re working on two sites, siteA.com and siteB.com. Like you said, I would create two folders in your www folder called siteA.com and siteB.com. I used to name the folders by client or site name, but I realized there’s no reason to complicate things. Just use the full site url for the folder name. Download a copy of wordpress into each folder, create two separate databases using WAMPSERVER’s phpmyadmin and then fire up localhost/siteA.com in your browser to complete the WP install. Do the same thing for siteB.com. It can be annoying to create a new database and go through the install for both sites, but it will eliminate headaches down the road especially if you’re using different page content during development.

Leave a Reply