## Sticky for virtual hosts - aka XAMPP will not start

Problems with the Windows version of XAMPP, questions, comments, and anything related.

### Sticky for virtual hosts - aka XAMPP will not start

EDIT: I should have added if anyone has a link to a GOOD simple virtual hosts "How To" for Win 10 I would be very very greatful.

I have successfully got up and running with virtual hosts on about 4 machines in the past. I am damned if I can get it working here so reinstalling XAMPP for the second time.

I want to be able to use foo.dev and bar.dev and just have them as URLs mapping their roots to directories htdocs\foo.dev and htdocs\bar.dev.

I have done this before on about 5 occasions but this is the problem - I can never remember exactly how I did it (edit host in etc, httpd.conf in apache\conf and httpd-vhosts.conf in extra).

Before I started fiddling around localhost was working fine and then when I changed all these files back nothing is working.

PLEASE can we have a sticky for setting up virtual hosts. I have Googled until my eyes bleed and seen so many contradictory methods.

If there was one method here, then, if it did not work we would all start from the same point when looking for help.

TIA Steve

PS A little guidance on Winows Event Viewer would also be nice in the error message or in the current sticky. I cannot find any useful info in WEV. My log on this installation was :

12:44:12 PM [main] Initializing Control Panel
12:44:12 PM [main] Windows Version: Home 64-bit
12:44:12 PM [main] XAMPP Version: 5.6.19
12:44:12 PM [main] Control Panel Version: 3.2.2 [ Compiled: Nov 12th 2015 ]
12:44:12 PM [main] Running with Administrator rights - good!
12:44:12 PM [main] XAMPP Installation Directory: "c:\xampp\"
12:44:12 PM [main] Checking for prerequisites
12:44:12 PM [main] All prerequisites found
12:44:12 PM [main] Initializing Modules
12:44:12 PM [main] Starting Check-Timer
12:44:12 PM [main] Control Panel Ready
12:44:15 PM [Apache] Attempting to start Apache app...
12:44:15 PM [Apache] Status change detected: running
12:44:16 PM [Apache] Status change detected: stopped
12:44:16 PM [Apache] Error: Apache shutdown unexpectedly.
12:44:16 PM [Apache] This may be due to a blocked port, missing dependencies,
12:44:16 PM [Apache] improper privileges, a crash, or a shutdown by another method.
12:44:16 PM [Apache] Press the Logs button to view error logs and check
12:44:16 PM [Apache] the Windows Event Viewer for more clues
12:44:16 PM [Apache] If you need more help, copy and post this
12:44:16 PM [Apache] entire log window on the forums
stevehomer

Posts: 3
Joined: 19. May 2016 12:31
XAMPP version: 5.6.19
Operating System: Win 10

### Re: Sticky for virtual hosts - aka XAMPP will not start

How about Apache's error.log and if nothing else, starting Apache from the command line?
It's a misspelled directive most likely but we'll see. Anyway, here goes;

File: c:\windows\system32\drivers\ect\hosts
Code: Select all
127.0.0.1     foo.dev
127.0.0.1     bar.dev

File: c:\xampp\apache\conf\httpd.conf
Take note what the DocumentRoot is in this file. You will need to know it later.
Uncomment the Include for httpd-vhosts.conf
Code: Select all
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

File: c:/xampp/apache/conf/extra/httpd-vhosts.conf
This has been working for me since Apache 1.3.0 back in 1998.
Code: Select all
# We can use "Define" in Apache 2.4 and it's surprising it is not used more
Define DOCROOT "c:/xampp/htdocs"

# The default (and first VirtualHost) must be pointed to the same DocumentRoot as the
# (global) DocumentRoot in httpd.conf

<VirtualHost _default_:80>
DocumentRoot "${DOCROOT}" </VirtualHost> # Now you can start adding more hosts # foo.dev <VirtualHost *:80> DocumentRoot "${DOCROOT}/foo.dev"
ServerName foo.dev
CustomLog /logs/ foo.access.log common
</VirtualHost>

# bar.dev
<VirtualHost *:80>
DocumentRoot "${DOCROOT}/bar.dev" ServerName bar.dev ServerAdmin webmaster@bar.dev CustomLog /logs/ bar.access.log common </VirtualHost> The "default" host will answer ALL requests to your IP not matching any configured hostname (in your case foo.dev & bar.dev). Because of this I always put no actual site there, just a page that says "There is no website at this address" If they come directly to my IP address and not any hostname (bots usually looking for vulnerable web apps) they get "Go Away!" gsmith Posts: 193 Joined: 29. November 2013 18:04 Location: San Diego XAMPP version: 0.0.0 Operating System: Win XP to 2012R2/VS 6,9,11,14 ### Re: Sticky for virtual hosts - aka XAMPP will not start stevehomer wrote:PLEASE can we have a sticky for setting up virtual hosts. Of course: https://httpd.apache.org/docs/current/en/vhosts/ I cannot make it a sticky, ask Bitnami (or "Altrea" here in this forum) to do so. Nobbie Posts: 8640 Joined: 09. March 2008 13:04 ### Re: Sticky for virtual hosts - aka XAMPP will not start gsmith wrote:How about Apache's error.log and if nothing else, starting Apache from the command line? Well added Code: Select all # We can use "Define" in Apache 2.4 and it's surprising it is not used more Define DOCROOT "c:/xampp/htdocs" # The default (and first VirtualHost) must be pointed to the same DocumentRoot as the # (global) DocumentRoot in httpd.conf <VirtualHost _default_:80> DocumentRoot "${DOCROOT}"
</VirtualHost>

# Now you can start adding more hosts

# foo.dev
<VirtualHost *:80>
DocumentRoot "${DOCROOT}/foo.dev" ServerName foo.dev ServerAdmin webmaster@foo.dev CustomLog /logs/ foo.access.log common </VirtualHost> # bar.dev <VirtualHost *:80> DocumentRoot "${DOCROOT}/bar.dev"
ServerName bar.dev
CustomLog /logs/ bar.access.log common
</VirtualHost>

... and still got the same error message. The Apache error logs just report an SSL error when it DOES launch and nothing where it does not. As I said i have not managed to get anything useful out of the Windows Event Viewer (something I have never played with). At an earlier stage I did play with changing port numbers and it seemed to work BUT I may well be wrong - I did not understand how the hosts file worked (and still do not fully).

And sorry not sure how to run Apache from command line.

Any thoughts
stevehomer

Posts: 3
Joined: 19. May 2016 12:31
XAMPP version: 5.6.19
Operating System: Win 10

### Re: Sticky for virtual hosts - aka XAMPP will not start

Nobbie wrote:Of course:
https://httpd.apache.org/docs/current/en/vhosts/

Yep well spent ages there. Was not a tad confusing. For example:

Each Virtual Host must correspond to a different IP address, different port number, or a different host name for the server, in the former case the server machine must be configured to accept IP packets for multiple addresses. (If the machine does not have multiple network interfaces, then this can be accomplished with the ifconfig alias command -- if your OS supports it).

BTW I don't see that we ARE using different IP addresses...

Then the examples they give are different in different places and different to the examples in the files... etc etc.

I was looking for a simple recipe to follow - that was what @gsmith gave - so we have a fixed starting point. I hope you see what I mean.
stevehomer

Posts: 3
Joined: 19. May 2016 12:31
XAMPP version: 5.6.19
Operating System: Win 10

### Re: Sticky for virtual hosts - aka XAMPP will not start

stevehomer wrote:BTW I don't see that we ARE using different IP addresses...

You are using name based virtual hosts, so you only need to have different host names for each virtual host.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers

Altrea
AF Moderator

Posts: 8248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

### Re: Sticky for virtual hosts - aka XAMPP will not start

stevehomer wrote:[I hope you see what I mean.

It's not that important as i know pretty well, how VirtualHosts are working.
Nobbie

Posts: 8640
Joined: 09. March 2008 13:04