PHP Development on your laptop

Setting up a PHP development environment

Setting up my laptop to be a PHP/MySQL server was easier than I would have predicted. Download the XAMPP package from Apache Friends at http://www.apachefriends.org and unzip it to c:\xampp (keeping the folder hierarchy intact). There are Windows and Linux versions, with Mac OS X version being developed. I’m writing about the Windows version.

Run c:\xampp\setup_xampp.bat and you have a functioning web server. Start it by loading c:\xampp\xampp_start.exe and you can load http://localhost/xampp/ in your web browser. The //localhost root is c:\xampp\htdocs

To have Xampp run automatically, set it up as a Windows Service. Run c:\xampp\xampp-control.exe and put check marks next to Apache and MySQL.

Xampp Control Panel


Since any PHP developer is likely to develop multiple websites, make a subfolder of htdocs for each website. There are some simple changes to make so each subfolder works as a subdomain (i.e. html links to /images work as expected for the site). Edit your C:\xampp\apache\conf\extra\httpd-vhosts.conf adding lines like the following (substitute your folder name instead of lernerc):

<VirtualHost local.lernerc.com:80>
DocumentRoot “C:/xampp/htdocs/lernerc/”
ServerName local.lernerc.com
ServerAdmin youremail@yourserver.com
<Directory “C:/xampp/htdocs/lernerc/”>
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

If you have a site in c:\xampp\htdocs\ot, you would use lines like this:

<VirtualHost local.ot.com:80>
DocumentRoot “C:/xampp/htdocs/ot/”
ServerName local.ot.com
ServerAdmin youremail@yourserver.com
<Directory “C:/xampp/htdocs/ot/”>
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Then you need to tell your operating system about new “domains”. In Windows, edit the C:\Windows\system32\drivers\etc\hosts file with lines like this:

127.0.0.1 local.lernerc.com
127.0.0.1 local.ot.com


Posted

in

by

Comments

2 responses to “PHP Development on your laptop”

  1. George Lerner Avatar

    @lami: Please give more details… How have you configured your system? What file is getting displayed in your web browser? Are you getting any error messages in your c:\xampp\apache\logs\error.log?

  2. lami Avatar

    I’ve tried this using XAMPP but all the virtual host keep redirecting (or) pointing to the same site…

    What do I do… (BTW I’m running XAMPP on Win XP)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.