logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: NameVirtualHost setup on development PC
Author
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Tue 30 Nov '10 23:18    Post subject: NameVirtualHost setup on development PC Reply with quote

Hi, I'm using my PC to develop more than one website, and wish to serve it to the local browser in Windows 7. I've installed the Webserv pack with Apache 2.2 and it has been working fine with just one site, but now I've tried to follow various instructions from the web and in the Apache documentation to set up a virtual host for a second site, and neither site works (unless I comment out the virtualhost conf file in httpd.conf, in which case http://localhost:8080 works again).

Starting Apache with -S suggests the syntax is correct but I don't know:

Code:

*:8080                 is a NameVirtualHost
         default server localhost (D:/WebServ/apache22/conf/extra/httpd-vhosts.conf:27)
         port 8080 namevhost localhost (D:/WebServ/apache22/conf/extra/httpd-vhosts.conf:27)
         port 8080 namevhost www.site2.dev (D:/WebServ/apache22/conf/extra/httpd-vhosts.conf:41)
Syntax OK


This is the code I've put in to define the two sites:

Code:

NameVirtualHost *:8080
<VirtualHost *:8080>
    DocumentRoot "D:/WebServ/wwwroot/site1.com/htdocs"
    ServerName localhost
    ErrorLog "D:/WebServ/logs/httpd/error.log"
    CustomLog "D:/WebServ/logs/httpd/access.log" common
</VirtualHost>

<Directory "D:/WebServ/wwwroot/site1.com/htdocs">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:8080>
    DocumentRoot "D:/WebServ/wwwroot/site2.dev/htdocs"
    ServerName www.site2.dev
    ServerAlias site2.dev
    ErrorLog "logs/site2-error.log"
    CustomLog "logs/site2-access.log" common
</VirtualHost>

<Directory "D:/WebServ/wwwroot/site2.dev/htdocs">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>


In addition to this, I've added aliases into the hosts file against 127.0.0.1, but when I try to open either site in my browser, it claims it can't establish a connection to the server at localhost:8080 or site2.dev:8080. If I comment out the virtualhosts conf line in httpc.conf, the default (original) site loads for either alias.

Well, I hope I've covered everything there! And hopefully it's something simple...
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 01 Dec '10 5:09    Post subject: Reply with quote

just curious, what is the documentroot configured in httpd.conf
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Wed 01 Dec '10 9:28    Post subject: Reply with quote

Hi,

I have the document root as:
Code:

D:/WebServ/wwwroot/site1.com/htdocs


Cheers
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 01 Dec '10 22:27    Post subject: Reply with quote

Ok, and that is what I see as your first vhost, which is correct. Apache calls it the default, which is correct.

I cannot believe this would be it but it is simple and worth a try, in that first vhost, change the *:8080 to _default_:8080

Hmmm ... is the server also running port 80?
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Thu 02 Dec '10 23:27    Post subject: Reply with quote

Hi,

No such luck... changing the first vhost to _default_:8080 made no difference.

I don't know where to look to see if the server is also running port 80. The httpd.conf file has Listen 8080 only.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 03 Dec '10 7:04    Post subject: Reply with quote

stumped

anyone else got any ideas?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Fri 03 Dec '10 10:56    Post subject: Reply with quote

Since it is ot allowed to post he whole config in the forum, you might post it on http://pastebin.com/ so we can try to reproduce the problem (do not forget the include (only used onces)).
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Sat 04 Dec '10 14:20    Post subject: Reply with quote

OK, I have pasted it here (with a 1 month expiry):

http://pastebin.com/1afMeqQp

Thanks for taking a look!
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Sat 04 Dec '10 16:54    Post subject: Reply with quote

PS - the vhosts line is commented out as pasted in httpd.conf (since I can then at least use one of the sites...)
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Mon 06 Dec '10 0:45    Post subject: Reply with quote

Does this folder exist?

D:/WebServ/apache22/logs
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Mon 06 Dec '10 12:22    Post subject: Reply with quote

Hmm... no.

There is a D:/Webserv/logs though.

Should I create a D:/Webserv/apache22/logs folder?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Mon 06 Dec '10 15:27    Post subject: Reply with quote

alphatucana wrote:

Should I create a D:/Webserv/apache22/logs folder?


Since you haven't defined ErrorLog "logs/phpbook-error.log" and not the full path and your ServerRoot is "D:/WebServ/apache22" Apache need the logs folder there
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Mon 06 Dec '10 17:41    Post subject: Reply with quote

OK; I've added the folder and uncommented the Vhosts call in httpd.conf but when I try to load the page with:

Code:
http://phpbook.dev:8080


I'm still getting the default site (I suppose adding the logs folder wasn't intended as the solution, but I thought I'd better check what happens).
Back to top
alphatucana



Joined: 30 Nov 2010
Posts: 8
Location: London

PostPosted: Mon 27 Dec '10 15:37    Post subject: Reply with quote

I've double-checked all the paths; I've made sure the log files exist in the indicated directory... and still, it is loading the wrong site with the above command... Sad

Any ideas? TIA.
Back to top


Reply to topic   Topic: NameVirtualHost setup on development PC View previous topic :: View next topic
Post new topic   Forum Index -> Apache