To use XAMPP for developing multiple web sites, specify a ‘host name’ for each web site to use. Each web site will have its own folder on your computer. Link a host name, to a folder with your web site files. Edit the web site files, view them on your web browser (skipping the normal FTP step for each change); when the page is working, publish it to the Internet.
You can define your own host names. Some people use .local for their naming convention (http://www.yourdomain.com on the Internet, http://www.yourdomain.local on your development computer). Or use local.yourdomain.com, which should be looked for on your computer before on the Internet. I like a simpler one, since I’m doing it only for me: yd.c (Yes, you can name it anything you want, on your own computer only). Two or three letter abbreviation, and .c, you’d be amazed how typing 4 characters instead of a long domain name, again and again, matters in developing and testing a web site.
You define “your own host name” in two places, one for XAMPP, one for Windows.
Host Names in Windows
For Windows: edit your hosts file:
C:\WINDOWS\system32\drivers\etc\hosts adding a new line for each “your own site” you make up. Whatever you specify here will be processed by XAMPP (the program serving localhost), when you type the name (e.g. yd.c) into your web browser address bar.
You may have to open Windows Explorer as Administrator, in order to access the folder. Right click the link in Start Menu, select “Run as Administrator”.
There must be a space between the IP address and the host name. No spaces are allowed in either the IP address or the host name.
Note: 127.0.0.1 as an IP address is a global convention for “this computer” (“the most-commonly used IPv4 loopback address”). Your hosts file probably has this line in it:
If it has some other IP address for localhost, use that IP address instead in your lines.
Host Names in XAMPP
C:\xampp\apache\conf\extra\httpd-vhosts.conf is the file where you tell XAMPP (installed on C:) to make a folder behave as a web site. You also specify what names from the Windows Hosts file, get matched with which XAMPP site.
F:\xampp\apache\conf\extra\httpd-vhosts.conf is the file where you tell XAMPP Portable, on F:, the same thing.
The file F:\xampp\htdocs\sitename\index.php should behave as http://somedomainname.com/index.php for your browser.
This should be there (probably is):
This says that if you type “localhost” into your browser address bar, (or more formally http://localhost/ ), it should display the file F:\xampp\htdocs\index.php (Note: all folder names in XAMPP should follow web site (UNIX) standards, using forward slashes / instead of Windows-style back slashes \ in all addresses. http://localhost/abcd.php should display F:\xampp\htdocs\abcd.php
Below those lines, add a section like this for each of your web sites. The lc.c (in the VirtualHost line and the ServerName line) matches the lc.c in the Windows Hosts file. The DocumentRoot line and Directory line have the full path name of the folder, but with forward slashes. The ServerAdmin line is an email address.
# reminder: must restart Apache for changes to take effect <VirtualHost lc.c:80> DocumentRoot "f:/xampp/htdocs/lernerc" ServerName lc.c ServerAdmin [email protected] ErrorLog f:/xampp/htdocs/lernerc/error_log ScriptLog f:/xampp/htdocs/lernerc/error_log <Directory "f:/xampp/htdocs/lernerc"> Options Indexes Includes FollowSymLinks MultiViews AllowOverride All Nonfatal=All Order allow,deny Allow from all </Directory> </VirtualHost>
Changes to XAMPP configuration files need a XAMPP restart to take effect.
XAMPP with Apache as a Windows Service: Use Windows Control Panel, Administrative Tools, Services (tip: right click on that, pin to Start Menu to make a shortcut), restart the Apache service.
XAMPP “normal”: Use F:\xampp\xampp-control.exe or F:\xampp\xampp_start.exe and F:\xampp\xampp_stop.exe (tip: xampp-control is where you assign Apache and other components to run as a Windows Service, obviously don’t do this with a portable installation.) Note: Xampp-Control will not work on the Apache Windows Service.
Now put a minimal HTML file in F:\xampp\htdocs\lernerc\test.html and in your web browser type http://lc.c/test.html (or simply lc.c/test.html ) and the page should display.