We've Always Got Something to Say.

Read our thoughts on what's happening in the industry.

January 25 , 2012

The “Complete” How-to Set Up XAMPP on Windows

by

If you run PHP locally on a Windows machine, you’re probably using XAMPP.  By default, you put all your files in the xampp directory (htdocs) to make things work.  However, if want a different directory structure (i.e. under “My Documents”) you can set up domain or subdirectory aliases.

The following steps are the mostly-complete guide to setting up XAMPP: set alternate folders/domains/subdirectories, enable “missing” extensions, and let it play nicely with VisualStudio’s local IIS.

  1. Download zip version
  2. run setup_xampp.bat to fix directories
  3. to access your local dev like `http://ALIAS.localhost:81/whatever.php`, in \apache\conf\extra\httpd-vhosts.conf add your custom directories like: (note port 81 from step 7)
    
    <VirtualHost *:81>
     ServerAdmin YOUR@EMAIL.COM
     DocumentRoot "/Relative/Path/To/LocalFiles"
     ServerName ALIAS.localhost
     ServerAlias www.ALIAS.localhost
     ErrorLog "logs/ALIAS.localhost-error.log"
     CustomLog "logs/ALIAS.localhost-access.log" combined
    
     <Directory "/Relative/Path/To/LocalFiles">
     Options Indexes FollowSymLinks
     AllowOverride All
     Order allow,deny
     Allow from all
     </Directory>
    </VirtualHost>
    

     

  4. Update your hosts file (C:\Windows\System32\drivers\etc\hosts) accordingly: 127.0.0.1 ALIAS.localhost
    (added bonus: wildcards in hosts file (untested))
  5. OR, instead of #3 and #4, configure subdirectory aliases in \xampp\apache\conf\extra\httpd-userdir.conf, which will let you access your local dev like `http://localhost/ALIAS/whatever.php`
    <IfModule alias_module>
     # ===== Description of the following
     Alias /ALIAS "/Relative/Path/To/LocalFiles"
     # Access control, etc
     <Directory "/Relative/Path/To/LocalFiles">
     AllowOverride All
     Options Indexes FollowSymLinks
     Order allow,deny
     Allow from all
     </Directory>
    </IfModule>
    
  6. Allow “missing” extensions by uncommenting dll line in \xampp\php\php.ini
  7. If also have IIS (VisualStudio) on same computer, you’ll need to change the ports (you can use other numbers)
    1. in \xampp\apache\conf\httpd.conf – change `Listen *:80` to `Listen: *.81`, `ServerName localhost:80` to `ServerName localhost:81`
    2. in \xampp\apache\conf\extra\httpd-ssl.conf – change `Listen 443` to `Listen 442`
    3. ignore the message in xampp-control that says it started on port 80 (that’s hardcoded)

About the Author

Jeremy Schwartz is a software developer with a broad range of programming experience from research, consulting, and academic settings. His favorite thing to do is refactor inefficient code into well-documented, elegant solutions using content-management systems and custom code. Or read books. Lots of books.

Leave a Reply

 

In a Nutshell

Since 1998, Atlantic BT has been a full service web development company that offers the tools, resources and services to get your business moving. We focus on combining new ideas, specific requirements, and years of experience into high-quality, results-oriented web solutions for small to medium sized businesses. If you want the best website possible that generates real results, let's get started.

Atlantic Business Technologies, Inc.
4509 Creedmoor Road, 3rd Floor
Raleigh, North Carolina 27612
  • Pinnacle Business Award Winner
  • Triangle Business Journal's Top 40 Under 40
  • Yahoo Search Marketing Ambassador
  • Google Adwords Qualified Company