How to Set Up a Local PHP/MySQL Development Sandbox for Windows and OS X


Set Up Local Testing Server

Editor’s Note: This is the first guest tutorial that we’ve decided to post on Build Internet since our launch. In this post Dixon has put together a visual guide to setting up a local development environment for testing PHP/MySQL driven websites. We’re excited to hear your feedback in the comments! – Zach

The Goal

By the end of this tutorial, we will have a fully working copy of Wordpress running from our local machine. We will accomplish this using an all-in-one package either called WAMP (for Windows) or MAMP (for Mac). WAMP/MAMP is an abbreviation of Windows/Mac – Apache – MySQL – PHP. As you could have guessed, this will get Apache Web Server, MySQL, and PHP up and running in one-click.

Why Test Locally?

To test, test, test! There is no payment from a client if the site you made for them goes down within 24 hours. That’s why you need to test all the aspects out before you push it live.

The first part of the tutorial will vary between operating systems, please find your own and follow along!

The Guide for Windows

Follow this link to find the WampServer download page and download the program. Run the installer once it completes. You will come to the following page:

wamp_install_1

You could specify a custom folder for WAMP to be installed but for the purposes of this tutorial, we will be using the default.

The next prompt will ask you to specify your default browser:

wamp_install_2

The default is Internet Explorer, but you could specify another browser as needed.

Next, you will come to a page asking about your SMTP settings if you will be using the PHP mail() function. As we are not going to be using this feature for this tutorial, just leave the defaults.

Hit finish and WampServer 2 will launch! Verify that everything is working correctly by launching your web browser and typing “localhost” into the address bar. You should see the following:

wamp_install_4You’ll also notice that a WAMP icon now appears in bottom task bar. This is a quick way to manage server functions from the desktop.

wamp_install_3


The Guide for Mac OS X

Mac users, we haven’t forgotten about you. Your testing environment will be from a wonderful little program called “MAMP”.

Download a MAMP installer from the official project website. It’s a little bit heavier of an install at 140 MB (compared to WAMP’s 16MB) Extract the DMG and drag the application to your Applications folder.

mamp_install_2

Run the Application and click on Preferences. Leave the settings as is under Start/Stop, make sure your Apache Port is 80 and your MySQL Port is 3306. Under PHP, you could use PHP 4 but for this tutorial we will be using PHP 5. Then, under Apache, you can set your document root to whatever you like.

That’s it! Start up your servers then browse to http://localhost/MAMP/ in your browser. If it’s running correctly you should see something like the following:

mamp_install_3

Let’s install Wordpress!

Go ahead and download the latest version of Wordpress. (Version 2.7.1 at time of publishing) Extract the file and open up the folder.

Copy all the files into ‘YourDocumentRoot/wp/’. For Windows, your document root should be ‘C:/wamp/www/’. For Mac, your document root should be ‘/Applications/MAMP/htdocs/’.

Next we have to create a database for the Wordpress install to use. We will use phpMyAdmin to do this.

  • On Windows browse to http://localhost/, then click on PhpMyAdmin towards the end of the page.
  • On Mac browse to http://localhost/phpMyAdmin/ to go straight there.

Once you’re in phpMyAdmin, you should see a page like this:

wordpress_install_1
Type ‘wordpress’ in the box and hit Create to create a new database.

Browse to where your Wordpress files are located (which should be http://localhost/wp/) Since we didn’t create our own wp-config.php file, Wordpress will create one for us.

wordpress_install_2

Next, you’ll come to the configuration form:

wordpress_install_3

What you enter will differ slightly whether you are on Windows or Mac, so here’s the info:

Windows
Database Name: wordpress
User Name: root
Password: (No Password)
Database Host: localhost
Table Prefix: wp_

Mac
Database Name: wordpress
User Name: root
Password: root
Database Host: localhost
Table Prefix: wp_

Once you enter your information correctly, you’ll be taken to the final install page:

wordpress_install_4

Click “Run the Install” and then you’ll be asked for some basic information about your blog: (You can always change this later)

wordpress_install_5

After you provide that basic information, you will be given your temporary password to login to your blog. Note this password carefully! If you forget it, you’ll have to reinstall!

And finally, you’ll find yourself at a log in page. Use your new account to access your fresh new local Wordpress install!

wordpress_install_7

That’s it! Go have fun with your web sandbox!

  • Stumble It!
  • Bookmark It!
  • Tweet it!

About Dixon Crews

Hey, I'm a 15 year old high school student who really loves web design and development from North Carolina, US. I'd love to go to school to learn even more about design, possibly computer science, and eventually having a job designing and developing websites! Follow Dixon on Twitter.

 

Discussion

  1. Ractoon

    May 16th, 2009 at 6:13 PM

    Local development definitely helps with efficiency. Don’t have to worry about network connection issues, and you’ll automatically have a backup once you migrate your files to the production server.

    Though I prefer to use XAMPP – http://www.apachefriends.org/en/xampp.html – cross platform with a variety of features.

  2. Joël Cox

    May 17th, 2009 at 5:13 AM

    OS X comes with Apache pre-installed, but isn’t configured in the way it should be. You can simply change the HTTPdocs root, download and install a MySQL package. Change the database socket in your Apache config and you’re ready to go.

    If you don’t fancy using a command line, these programs (and XAMPP) are great alternatives, but I just hate to have two similar programs installed on my system :D

    Joël Cox’s last blog post..Review: De wet op internet

  3. mkjones

    May 17th, 2009 at 5:21 AM

    Yep XAMPP – http://www.apachefriends.org/en/xampp.html – is a FAR better resource for this. No need to install and you can run it from a memory stick.

    Always handy when freelancing.

  4. IntensiveSoft

    May 17th, 2009 at 10:27 AM

    Think xampp is the better alternative, but there are some stuff that i dont like in the bundle. For that reason I still use easyphp as testing server.

  5. Zach Dunn

    May 17th, 2009 at 12:31 PM

    I have a question for the crowd after reading some of the comments recommending XAMPP:

    What is a selling point of XAMPP over using MAMP (my current choice) if you always develop on the same machine, and being portable isn’t really necessary?

    From my experience MAMP is absolutely wonderful, and does everything I’d expect it to. If XAMPP has some big advantages that I’m missing out on, please share!

  6. Sean O

    May 17th, 2009 at 11:34 PM

    Many of these packages work pretty well, but I think MoWes is the best of the bunch.
    http://www.chsoftware.net/en/useware/mowes/mowes.htm
    Most major packages: WordPress, Drupal, Moodle, etc. are available to download, pre-installed.

    Sean O’s last blog post..Bubble Spinner

  7. Guillaume Moigneu

    May 18th, 2009 at 1:54 AM

    The problem with MAMP is that everything is hidden. Editing php config is a real pain and it is hard to use the cli executable.

    My current choice of sandbox is a debian configured as a LAMP platform running on VMWare with an AppleShare folder.

    Guillaume Moigneu’s last blog post..[Symfony] Générer les fixtures à partir de la DB

  8. Dixon Crews

    May 18th, 2009 at 8:27 PM

    Seems MAMP isn’t the preferred article amongst you guys. Well, I like it. :P

  9. Viking Beard

    May 19th, 2009 at 10:03 AM

    Thank you so much! Apache and phpMyAdmin was completely bizarre to me before this tutorial. I appreciate having the screencaps included!

  10. Marty Thornley

    May 20th, 2009 at 3:29 AM

    Dixon,

    Great tutorial for a subject I don’t see mentioned enough. And Zach – this was a great choice for a first guest post. MAMP is a huge benefit for anyone developing WordPress themes and a set-up like this should be getting more attention than it does.

    I have used MAMP for a while now and love it. There may be some advanced PHP things you can’t get at, but I wouldn’t know. I have used it out of the box to set-up and build WordPress sites no problem.

    MAMP speeds up development of a new site and makes you realize just how much time you spend waiting for a page to refresh just to test a quick change. I can’t imagine going back.

    -Marty

    Marty Thornley’s last blog post..WPJumpStart – Build WordPress Themes Faster

  11. michelle

    June 4th, 2009 at 5:55 AM

    Thanks heaps! I couldn’t get my local WordPress sites running after transferring them over from a Windows machine running XAMPP. I figured out that Mac needed the password for the database to be set but still couldn’t get them running. Changing the default Apache and mySQL ports was all that was necessary!

    Thanks again!

  12. Sayz

    June 8th, 2009 at 3:19 PM

    I use XAMPP, it was the first time I got Mac OSX and search Google. It works well, except I don’t really understand how it works…

  13. Ace Newman

    June 22nd, 2009 at 6:16 AM

    XAMPP is the very best. It’s cross-platform, and also packs Perl with it. Way to go!

  14. AmyHewitt

    October 2nd, 2009 at 5:33 PM

    Great tutorial, interesting and informative.

  15. Georgie

    October 24th, 2009 at 6:34 AM

    Really great tutorial – thank you so much. Exactly what I need to learn, very clear, incredibly helpful!

  16. Patrick

    October 24th, 2009 at 2:08 PM

    Why using MAMP? OS X comes with Apache and PHP “onBoard”, just install a MySQL and you’re fine.

  17. Dixon Crews

    October 24th, 2009 at 3:36 PM

    Yes, it does, but I find it much easier to configure MAMP and get it running.
    .-= Dixon Crews´s last blog ..dixoncrews: Got the MBP back…all shiny and new screen :) =-.

  18. Mr.Nguyen

    December 22nd, 2009 at 12:54 PM

    Great tutorial, i like it,thanks for share

Join the Conversation!

Remember: Life's not all doom and gloom, so please keep it constructive. If we've made an error or missed something big, please let us know! Learning is revisions, after all.

CommentLuv is Enabled

 

Sponsors

Advertise on Build Internet!