Here is a brief how to set up virtual hosts on Vista. It may or may not be guaranteed to work on your system. However, it worked for me and I thought it worth sharing:
you have installed Xampp on Vista and made sure to put the installation in a directory other than Program Files.
When you type http://localhost, you can reach the Xampp start screen (redirecting to http://localhost/xampp/ )
You have already set permissions by going to http://localhost/security/index.php so that your setup is secure.
Where Things Are Your config files will be in this directory
However, if you want to create virtual hosts (that is, to go to www.myhost.com and www.myhost1.com on your local computer), the main file you will be editing will be C:\apache\xampp\apache\conf\extra\httpd-vhosts.conf
1. Before you do any editing, make a backup copy of httpd-vhosts.conf and htttpd.conf
2. Making sure your fake hosts resolve on your local machine. To do that, you need to edit your C:\WINDOWS\system32\drivers\etc\hosts file.
With Vista, there is a special trick. You can't merely doubleclick on the HOST file in Windows Explorer. You need to start Notepad first by rightclicking the Notepad shortcut on your Start menu and choosing "Run as Administrator". (This is a security mechanism that forces users to elevate privileges on the program itself). Hint: by default the Host file won't appear when you are browsing to that directory. You need to make sure that when you are browsing with the Open option that you not limit your searches to only txt files. To do that, change the filter in the Open window to All files (*.*)
Here is my host file. Note that I want to use a fake domain called http://read.local
- Code: Select all
3. Make sure you start Xampp as a Administrator. To do that, right-click the Xampp icon shortcut, and choose Run As Administrator.
4. Create a directory which you want to be your root for your fake host
I created I:\My Documents\websites\ and then I will be putting my directories for fake domains underneath it like this
5. Make sure to put an index.html or index.php file inside this new directory.
6. Edit your httpd-vhosts.conf file:
Here is mine:
- Code: Select all
#DocumentRoot "C:/apache/xampp/htdocs" doesn't work
DocumentRoot "I:\My Documents\websites\read"
#DocumentRoot "I:/My Documents/websites/read" doesn't work
#<Directory "I:/MyDocuments/websites/read"> doesn't work
<Directory "I:\My Documents\websites\read">
Options Indexes FollowSymLinks Includes ExecCGI
Allow from all
Let's explain this.
a. NameVirtualHost *:80 is required. Here you are telling apache: hey, I want to associate multiple Internet host names with a single port/IP address.
b. When you use NameVirtualHost, you need to remind Apache how to get to the original htdocs root. Doing this will cause http://localhost to work as it did before you used virtual hosts/name based hosting. [/list]
c. I copied the file path from Windows Explorer. In other words, I went to the top address bar when I was in the right path in Windows Explorer and copied it. Note that I put everything inside quotation marks. That is required for Vista to be able to understand the path.
7. Open up a command line to doublecheck your syntax. This will catch the obvious errors.
Run, cmd, C:\apache\xampp\apache\bin\apache -t
(this will check your syntax)
Another helpful command to identify virtualhosting errors is apache -S
Other commands, try apache -h
I've been told that trying to start/stop apache via this command line does not work. You need to start it from the Xampp interface (or the Windows services menu if you have made it a Windows service).
8. Make sure your Xampp control panel is running as Administrator. (See step 3 above).
If Svc is unchecked, the Stop button will be visible. Stop apache, and then Start it.
(If you make apache a service, I think you need to stop/start under the Window services (in Administrative Tools on the control panel). But I prefer not to run it as a service.
9. After restarting apache using Xampp control panel, check http://localhost and http://read.local .
1. if your browser shows an access problem, that probably means that the Windows path you have pasted is not correct (or not in quotations).
2. The log files are usually listed here C:\apache\xampp\apache\logs (If you want to keep a running view of a log file, download the freeware Baretail http://www.baremetalsoft.com/baretail/).
It is not necessary for you to create the log file. Apache will do it automatically for you.
It is possible to change the noiseness of your logs by editing httpd.conf file.
- Code: Select all
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#LogLevel debug USE THIS TO HAVE VERBOSE ERROR MESSAGES
Important: Debug should only be used when testing. Normally you should only use warn or info.