Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/theme.php on line 623

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tantan/tantan_reports.php on line 143

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 79

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 118

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 122

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 126

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 130
How To Setup A Local Development Environment In Windows Using Apache, PHP, and MySQL

Thursday, March 22nd, 2007...10:48 am

How To Setup A Local Development Environment In Windows Using Apache, PHP, and MySQL


Deprecated: Function eregi() is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tpbc.php on line 96

For a long time I used to code on the fly, downloading files, making changes, then reuploading them to the server. It’s a nauseatingly slow way of doing things and if you make a mistake somewhere you’ve just killed your website.

So when I started getting serious about developing I switched to a local development environment. For most of the work I do this involves an Apache web server, PHP, and a MySQL database server. This setup is also perfect to use with WordPress. You can test your changes locally before committing them to your live server.

Now you might be thinking there’s alot of effort involved in setting up a test server like this but really it’s quite straight forward and I’ll take you through those steps now.

First of all you need to download the installation files. We’ll be working with the latest versions of each. Make sure to get the Windows versions that come with an installer.

Once you’ve downloaded those three files your ready to begin. We’ll start with Apache.

Installing Apache

This is all pretty straight forward.

Run the Apache .msi install file, and follow the prompts until you get to the window that asks for server information. Enter the following:

  • Network Domain: localhost
  • Server Name: localhost
  • Administrator Email: any email address

 

Keep following the prompts until Apache is installed.

To test everything is working properly open up a browser and enter localhost as the URL.

If Apache has been installed correctly and the server is running the text should read: It Works!

 

Installing PHP

Next up is PHP. Again this is pretty straight forward.

Run the PHP .msi install file.

When prompted to choose a Web Server select Apache 2.2.x Module.

Next you will be asked for the Apache Configuration Directory. You will want to navigate to where you installed Apache and find the conf directory.

In my case I installed Apache in the default directory so this is where I pointed the installer:

C:\Program Files\Apache Software Foundation\Apache2.2\conf

The next step is important otherwise PHP won’t be able to work with MySQL.

The MySQL extension for PHP isn’t automatically selected so you will have to go in and choose it manually. While your there you may want to see if there are any other extensions you want installed.

Follow the prompts to complete the install. Afterwards you will be asked if you want the installer to configure Apache. Click Yes, and your done installing PHP.

 

Installing MySQL Server

Unpack the zip file and run Setup.exe.

For setup type, choose typical install.

Once MySQL Server is installed skip the signup and move onto configuration.

Select Standard Configuration and continue.

Leave Install As Windows Service checked and continue.

Next you will be prompted for a password. This is the password you will enter whenever you use the MySQL Command Line Client.

Once that is done MySQL server will be configured and then start up. The MySQL server is now installed.

 

Getting It All Working Together

Now we’re almost done. There’s just a few things left to configure manually and then your good to go.

First off you want to go back to where you installed Apache and go into the conf directory. Open up the file “httpd.conf”.

Look for this text:

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

Change the middle line so that it reads:

DirectoryIndex index.html index.php index.php5

Now the next change is optional. By default the directory that will contain your html files will be htdocs in the Apache directory. I prefer to use a directory in a more easily accessible location so I changed it. To do that you need to change the following two lines.

DocumentRoot “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs”

<Directory “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs”>

Congratulations you’ve now completed the Apache/PHP/MySQL install.

 

One More Tip To Help You Get Started

Creating a new MySQL database using the command line client can be a little intimidating so here’s a small tutorial on how it’s done.

First of all open up the MySQL command line client. Enter the password you chose during the MySQL installation.

A prompt will be displayed that looks like this:

mysql>

To create a database called my_database we would enter the following at the prompt:

CREATE DATABASE my_database;

Next we need to create a user and assign that user privileges.

To create a user with all privileges to my_database, with the username johndoe and password turnkey you would enter the following at the prompt:

grant all privileges on my_database.* to johndoe@”localhost” identified by ‘turnkey’;

All done.

Have fun with your new test server.

16 Comments

  • yay for WAMP installs!

    I use WAMP here at home, but I perfer LAMP and do so when I have the resources. Something about Linux is just so much more fun than windows :)

  • Yeah ive got a LAMP setup on my Ubuntu box, I am messing around with making a custom theme for my blog, and it is so easy to just save the files then refresh rather than having to upload.

  • Nice tutorial man but i prefer using Easy PHP , its also good .

  • I personally use a package called Wampserver which installs all of those packages in 5 minutes…it also provides a handy icon in the taskbar to allow for editing of all configuration files. You should check it out.

    Mark

  • Mark I’m a bit of a tinkerer so I like getting in there and doing it myself but wampserver does look like a good alternative for people who just want to get it up and running quickly.

  • I was a tinkerer myself too but for about a year or so, I’m just using wamp, lamp, xampp whatever is handy at the moment to get the job done.

    I don’t do much local development these days that might be the reason for it -I usually have a server set up somewhere.

    but you must admit that the ability to point and click to activate extensions etc is a cool thing :)

  • [...] read more | digg story [...]

  • Wabwire Wandera
    April 14th, 2007 at 7:41 am

    After following ur procedures and trying to restart apache i get an error message something to do with PHPdir. What could be the problem

  • Wabwire - It sounds like the PHP settings weren’t added to the httpd.conf file. Have you tried reinstalling PHP?

  • the download for apache does not go though
    May 18th, 2007 at 3:12 am

    the download for apache does not go through

  • Dan, I wish I would have read your post a little earlier…I just went through the same process to setup a local dev environment on a spare server at home. I just posted my experience if you are interested in taking a look. I agree, if you have a little patience and some spare time I definitely recommend setting up some sort of development environment that mimics your “live” blog setup. It could really save a headache or two in the future (especially if you are like most and tend to modify your theme after the fact). Great tutorial!

  • great! thanks for sharing,

  • Many thanks for the test server setup instructions!!

    Took me all of 10 minutes to do, otherwise it would have taken ne 10 hrs!

  • I think I got most of it installed correctly, when I browse to localhost I see the directory tree and the files I have there but when I try to open a .php file I get a dialog window in both Firefox and IE asking me to save or open, if I choose open I get the same dialog box again. I can’t get it to compile. Any ideas? Thanks

  • Never mind on that one, I missed a step. I didn’t change DirectoryIndex index.html to DirectoryIndex index.html index.php index.php5…

  • I tried installing these with xampp package but had no luck geting it to work. Your simple tutorial got me up and running and despite having to download everything seperately I actually spent less time in the end. Thankyou!

Leave a Reply

You must be logged in to post a comment.

Blogarama - The Blog Directory Personal Blogs - Blog Top Sites Link With Us - Web Directory