How to create specific virtual hosts?

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

How to create specific virtual hosts?

Postby spriteork » 07. January 2009 12:03

Hi all.
Please suggest me how to create specific virtual local hosts with specific address(for example www.spriteork.com) and specific folder for site(for example D:\site)

As I read Apache manual, i must edit
....\xampp\apache\conf\extra\httpd-vhosts.conf
I'm edit it, adding there all as wrote in manual, creating host folder, writing test file index.php with some php code, saving it in that folder. When trying to open virtual host in browser, but nothing happen, browser writes error "site not found"

Advance thanks for help
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby Sharley » 07. January 2009 12:20

Please paste here your httpd-vhosts.conf file so we can see what you have done already - it will be easier to work with this file and paste back a possible solution.

A forum search for vhost or virtualhost will also give you many examples from the many previous posts on this subject.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 12:28

I'm delete all that i add and restart xampp because virtual host didn't create
[httpd-vhosts.conf]
--------------------------------------------------------------------------------
#
# Virtual Hosts
#
# 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.2/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 /www/docs/dummy-host.example.com
## ServerName dummy-host.example.com
## ServerAlias www.dummy-host.example.com
## ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
## CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
##</VirtualHost>

##<VirtualHost *:80>
## ServerAdmin webmaster@dummy-host2.example.com
## DocumentRoot /www/docs/dummy-host2.example.com
## ServerName dummy-host2.example.com
## ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
## CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
##</VirtualHost>

--------------------------------------------------------------------------------
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby Sharley » 07. January 2009 12:47

Try this - just copy and paste over your existing httpd-vhost.conf file.

I am assuming that XAMPP is in the default location C:\xampp
If not change the first DocumentRoot to your own path to htdocs.
Code: Select all
#
# Virtual Hosts
#
# 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.2/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 /www/docs/dummy-host.example.com
##    ServerName dummy-host.example.com
##    ServerAlias http://www.dummy-host.example.com
##    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
##</VirtualHost>

##<VirtualHost *:80>
##    ServerAdmin webmaster@dummy-host2.example.com
##    DocumentRoot /www/docs/dummy-host2.example.com
##    ServerName dummy-host2.example.com
##    ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
##</VirtualHost>

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName spriteork.com
ServerAlias www.spriteork.com
DocumentRoot "D:/site"
<Directory "D:/site" >
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Save the file and restart Apache.

If it won't start double click on the .\xampp\apache_start.bat file and it will give you a detailed error message.

EDIT
Syntax error fixed - sorry didn't proof read correctly, in too much of a hurry. tut tut.
Last edited by Sharley on 07. January 2009 23:53, edited 1 time in total.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 14:05

He wrote error when I launch apache:
----------------------------------------------------------------------------------------------------
Apache 2 is starting ...
apache.exe: Syntax error on line 502 of D:/xampp/apache/conf/httpd.conf: Syntax
error on line 49 of D:/xampp/apache/conf/extra/httpd-vhosts.conf: Expected </Vir
tualHost> but saw </Directory>

Apache konnte nicht gestartet werden
Apache could not be started
Press any key for continue
-----------------------------------------------------------------------------------------------------
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby Nobbie » 07. January 2009 14:10

You must also assign a valid IP to the domain http://www.spriteork.com

If you dont have registered this domain via a public DNS provider, you must supply the IP on your own (but is valid only for your local PC or your LAN). Therefore you have to edit the file c:\windows\system32\drivers\etc\hosts and append the following line:

127.0.0.1 http://www.spriteork.com

There is no need to restart Apacher neither to reboot the PC, simply enter http://www.spriteork.com in your browser and see what happens.
Nobbie
 
Posts: 13171
Joined: 09. March 2008 13:04

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 14:15

Where i must paste this string "127.0.0.1 http://www.spriteork.com"?
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby glitzi85 » 07. January 2009 14:16

The error you get while starting comes from an mistake in the configuration posted by Sharley. Replace

Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</Directory>
</VirtualHost>


with

Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>


glitzi

PS: Paste the Line in the File posted by Nobbie!
Last edited by glitzi85 on 07. January 2009 14:16, edited 1 time in total.
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 14:16

Ok, understand, try to do it
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 14:26

Writes error, Apache don't launching:
------------------------------------------------------------------------------
Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...
(OS 10048)╬с√ўэю ЁрчЁх°рхЄё  юфэю шёяюы№чютрэшх рфЁхёр ёюъхЄр (яЁюЄюъюы/ёхЄхтющ
рфЁхё/яюЁЄ). : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

Apache konnte nicht gestartet werden
Apache could not be started
Press any key for continue....
-----------------------------------------------------------------------------
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40

Re: How to create specific virtual hosts?

Postby spriteork » 07. January 2009 14:37

All start work after adding host to D:\WINDOWS\system32\drivers\etc\hosts

Thank you all
spriteork
 
Posts: 7
Joined: 07. January 2009 11:40


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 133 guests