Skip to main content Skip to secondary content

Local PHP Development

No comments

Many developers have their own techniques for improving the local development experience. I used to do all my development live, but I have found that model too restrictive as of late. Currently, the local development model I use involves XAMPP and InstantRails. XAMPP I use for PHP / Perl development, and InstantRails I use for Ruby / Rails development. My editor of choice has recently become e-texteditor.

XAMPP for Windows

XAMPP, a free, cross-platform stand alone server, is centered around the popular Apache web server. Along with Apache I have access to a MySQL server, and interpreters for PERL and PHP. The installation is very easy, and with a few modifications post installation you can have a great development environment.

After XAMPP Installation

Being able to work on multiple sites at once locally is critical. What is also critical is staying efficient. I made the decision early on in my setup that I didn’t want to have to type localhost/path/to/project for each new project. To take care of this issue I had to modify the /path/to/xampp/apache/conf/extra/httpd-vhosts.conf file, and the C:\WINDOWS\system32\drivers\etc\hosts file. You may also have to modify the /xampp/apache/conf/httpd.conf file if the following line of code is commented out (around line 500ish):

  1. Include conf/extra/httpd-vhosts.conf

To uncomment you may need to remove the pound sign preceding the code.

httpd-vhosts.conf

Here we are setting up virtual hosts to direct a url to a folder housing an app. The url should reflect the application you are building. For example:

  1. NameVirtualHost 127.0.0.1:80
  2. <VirtualHost 127.0.0.1:80>
  3. DocumentRoot "C:/Path/to/xampp/htdocs/"
  4. ServerName localhost
  5. ServerAdmin admin@localhost
  6. </VirtualHost>
  7. <VirtualHost local.app.com:80>
  8. DocumentRoot "C:/path/to/development/folder"
  9. ServerName local.app.com
  10. ServerAdmin admin@local.app.com
  11. <Directory "C:/path/to/development/folder">
  12. Options Indexes FollowSymLinks
  13. AllowOverride FileInfo
  14. Order allow,deny
  15. Allow from all
  16. </Directory>
  17. </VirtualHost>

For each new application you want to work with just repeat lines 2 - 17 in the above example and fill in the appropriate data. It’s important to note that the server name for your app (line 09) can be anything you want. It’s a good idea to keep it relevant to the application you are developing. It’s also important to note that for any change you make to your apache configuration you will likely have to restart the server to see those changes take affect.

C:\WINDOWS\system32\drivers\etc\hosts (win XP)

The last thing you need to do is to modify your windows host file. This instructs windows to point URLs typed into the address bar to a specific IP address. In our case, 127.0.0.1, the local IP address.

  1. 127.0.0.1 localhost
  2. 127.0.0.1 local.app.com

If you compare the above two code snippets, you will notice that local.app.com will load our local IP, and our virtual host instructs the server to point this URL to the specified directory. Adjusting the above two files for each new application should result in smoother development.

You can find a lot more information about using XAMPP (Apache-MySQL-PHP-Perl) for Windows online.

During development I also version the applications I am working on with Subversion, however that is a topic for another time.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Articles

Recent Comments

Teach Me the Web Relaunch

  • Mike Ames - October 25, 2008 12:04 pm I am still doing web projects on my own but our school does...
  • Jeff - October 24, 2008 6:15 am Mike, good to hear from you. I use Expression Engine to manage...
  • Mike Ames - October 23, 2008 8:22 pm Alright Boss, I got a few questions / Comments 1st. I hear...

I’m Married

  • Stefan Vervoort - June 4, 2008 2:43 pm Congrats, happy marriage!
  • Jeff - March 3, 2008 4:19 pm Much appreciated. Look at you with your shameless plug for your new...

We’ve Changed Our Name

  • leveille - May 22, 2008 3:29 pm hmmmm. I wonder what prompted this change.

Why iGoogle has changed my life

  • Mike Ames - May 8, 2008 9:33 pm I love i-Google for a few reasons some of which were mentioned....

What’s Popular?

  • Zac Gordon - March 17, 2008 7:32 pm I hear that! http://del.icio.us/zacgordon/w ebdesign Be...