VirtualHost - config file httpd-vhosts.conf not work

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

VirtualHost - config file httpd-vhosts.conf not work

Postby marshallfey » 24. November 2015 11:08

Hello,

I have install Xampp 5.6.14 on VPS Windows Server 2012 R2 Standard. I point ip to VPS with domain example.org and it work correct (load ok) but i want add more than one website on VPS so i config file httpd-vhosts.conf. But it dont work, it load website example.org and not load website i want.
Domain is example.com
IP is 123.123.123.123
Email is email@example.com
I have read http://httpd.apache.org/docs/2.4/vhosts/ but try config and not ok. I have stop and restart Apache and MySQL.
# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias http://www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>


I try to config is:
# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias http://www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
##ServerAdmin email@example.com
##DocumentRoot "C:/xampp/htdocs/example"
##ServerName example.com
##ServerAlias http://www.example.com
##ErrorLog "logs/example.com-error.log"
##CustomLog "logs/example.com-access.log"
##</VirtualHost>




Please help, thank you very much.
marshallfey
 
Posts: 3
Joined: 24. November 2015 10:36
Operating System: Windows Server 2012 R2

Re: VirtualHost - config file httpd-vhosts.conf not work

Postby Nobbie » 24. November 2015 11:33

If you do not remove all leading "#" in your rows, your config contains only comments. Only rows without '#' in the beginning are recognized.
Also look into httpd.conf, if httpd-vhosts.conf is really included (and not commented out, again via "#" in the beginning).

And: if you define at least only one VirtualHost, all external (not VirtualHosts) declarations of ServerName, DocumentRoot etc. are ignored! That means, if you define a VirtualHost for your example.com, you *should* also declare a VirtualHost for "localhost", otherwise you wont have any localhost anymore (it would yield to example.com instead).
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: VirtualHost - config file httpd-vhosts.conf not work

Postby marshallfey » 24. November 2015 12:01

I have remove ##
<VirtualHost *:80>
ServerAdmin email@example.com
DocumentRoot "C:/xampp/htdocs/example"
ServerName example.com
ErrorLog "logs/example.com-error.log"
CustomLog "logs/example.com-access.log"
</VirtualHost>
and then i stop Apache and MySQL and start it again is: Apache not ok
11:58:17 AM [Apache] Attempting to stop Apache (PID: 1612)
11:58:17 AM [Apache] Attempting to stop Apache (PID: 2500)
11:58:17 AM [Apache] Status change detected: stopped
11:58:19 AM [mysql] Attempting to stop MySQL app...
11:58:19 AM [mysql] Status change detected: stopped
11:58:22 AM [Apache] Attempting to start Apache app...
11:58:26 AM [mysql] Attempting to start MySQL app...
11:58:26 AM [mysql] Status change detected: running
11:58:30 AM [Apache] Attempting to start Apache app...
11:58:31 AM [Apache] Status change detected: running
11:58:31 AM [Apache] Status change detected: stopped
11:58:31 AM [Apache] Error: Apache shutdown unexpectedly.
11:58:31 AM [Apache] This may be due to a blocked port, missing dependencies,
11:58:31 AM [Apache] improper privileges, a crash, or a shutdown by another method.
11:58:31 AM [Apache] Press the Logs button to view error logs and check
11:58:31 AM [Apache] the Windows Event Viewer for more clues
11:58:31 AM [Apache] If you need more help, copy and post this
11:58:31 AM [Apache] entire log window on the forums

, and MySQL ok. So i have backup file httpd-vhosts.conf first and copy replace (C:\xampp\apache\conf\extra\httpd-vhosts.conf) and start Apache and MySQL again and result is all ok.
11:58:22 AM [Apache] Attempting to start Apache app...
11:58:26 AM [mysql] Attempting to start MySQL app...
11:58:26 AM [mysql] Status change detected: running
11:58:30 AM [Apache] Attempting to start Apache app...
11:58:31 AM [Apache] Status change detected: running
11:58:31 AM [Apache] Status change detected: stopped
11:58:31 AM [Apache] Error: Apache shutdown unexpectedly.
11:58:31 AM [Apache] This may be due to a blocked port, missing dependencies,
11:58:31 AM [Apache] improper privileges, a crash, or a shutdown by another method.
11:58:31 AM [Apache] Press the Logs button to view error logs and check
11:58:31 AM [Apache] the Windows Event Viewer for more clues
11:58:31 AM [Apache] If you need more help, copy and post this
11:58:31 AM [Apache] entire log window on the forums
12:01:38 PM [mysql] Attempting to stop MySQL app...
12:01:38 PM [mysql] Status change detected: stopped
12:01:39 PM [Apache] Attempting to start Apache app...
12:01:39 PM [Apache] Status change detected: running
12:01:42 PM [mysql] Attempting to start MySQL app...
12:01:42 PM [mysql] Status change detected: running


Please help me slove problem. Thank you.
marshallfey
 
Posts: 3
Joined: 24. November 2015 10:36
Operating System: Windows Server 2012 R2

Re: VirtualHost - config file httpd-vhosts.conf not work

Postby Nobbie » 24. November 2015 15:15

Look into the error log, you made any kind of error in your Virtualhost declaration.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: VirtualHost - config file httpd-vhosts.conf not work

Postby marshallfey » 24. November 2015 15:47

Error log is here, please view it and help me, thank you. Error log: http://example.org/download/error.log .
marshallfey
 
Posts: 3
Joined: 24. November 2015 10:36
Operating System: Windows Server 2012 R2

Re: VirtualHost - config file httpd-vhosts.conf not work

Postby Nobbie » 04. January 2021 16:15

Its the wrong error log, you need the error log from the VirtualHost example.com

P.S.: example.com is up and running - what are you doing there? And why dont you know anything about Apache configuration? This board is not meant for teaching Apache, it is meant for technical problems with Xampp (for Windows). You should read tutorials and documentation about Apache configuration, if you are unsure how to configure Apache. It is a pain for me to debug your configuration remotely.


Last bumped by marshallfey on 04. January 2021 16:15.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 96 guests