You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marco Bascietto <in...@bask.it> on 2004/03/19 19:07:20 UTC
[users@httpd] Name based Virtual Hosting
Hello all,
I am having a very trivial problem with NMVH. Apache is a rather new
land for me and I can't figure out what I am doing wrong, even after
reading FAQ and manuals.
Basically I want to set up 2 NMVH to make apache point to 2 sites I have
on my local machine.
What I have done:
1. added the domains www.foo1.com and www.foo2.com to the hosts file, it
now looks like this:
127.0.0.1 localhost.localdomain localhost www.foo1.com www.foo2.com
2. added 2 VH to httpd.conf:
NameVirtualHost http://localhost:80
<VirtualHost http://localhost>
ServerName www.foo1.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost http://localhost>
ServerName www.foo2.com
DocumentRoot /home/bask/documents/sites/foo2
</VirtualHost>
3. called both http://www.foo1.com and http://www.foo2.com from the
browser. They both point to /var/www/html, the DocumentRoot of the first VH.
The question is: how can I activate the second VH?
And secondly, when the second VH will work:
a. what kind of file permissions should I give to its DocumentRoot? the
same owner:group as defined in httpd.conf?
b. how can I make apache see the files in the DocumentRoot?
Thank you!
--
marco
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Name based Virtual Hosting
Posted by David <ap...@bensonresearch.com>.
On Friday 19 March 2004 10:07 am, Marco Bascietto wrote:
> Hello all,
>
> I am having a very trivial problem with NMVH. Apache is a rather new
> land for me and I can't figure out what I am doing wrong, even after
> reading FAQ and manuals.
> Basically I want to set up 2 NMVH to make apache point to 2 sites I have
> on my local machine.
> What I have done:
> 1. added the domains www.foo1.com and www.foo2.com to the hosts file, it
> now looks like this:
> 127.0.0.1 localhost.localdomain localhost www.foo1.com www.foo2.com
>
> 2. added 2 VH to httpd.conf:
> NameVirtualHost http://localhost:80
> <VirtualHost http://localhost>
> ServerName www.foo1.com
> DocumentRoot /var/www/html
> </VirtualHost>
> <VirtualHost http://localhost>
> ServerName www.foo2.com
> DocumentRoot /home/bask/documents/sites/foo2
> </VirtualHost>
>
> 3. called both http://www.foo1.com and http://www.foo2.com from the
> browser. They both point to /var/www/html, the DocumentRoot of the first
> VH. The question is: how can I activate the second VH?
>
> And secondly, when the second VH will work:
> a. what kind of file permissions should I give to its DocumentRoot? the
> same owner:group as defined in httpd.conf?
> b. how can I make apache see the files in the DocumentRoot?
>
> Thank you!
>
> --
> marco
>
Hi Marco, I'm using the following and it seems to work... Hope it helps
you...
NameVirtualHost *
# www.SomeSite.com
<VirtualHost *>
ServerName www.somesite.com
ServerAlias somesite.com
DocumentRoot /home/user1/public_html
ScriptAlias /cgi-bin/ "/home/user1/public_html/cgi-bin/"
ServerAdmin whoever@somesite.com
CustomLog /var/log/apache/vhost/www.somesite.com.log combined
</VirtualHost>
# www.AnotherSite.com
<VirtualHost *>
ServerName www.anothersite.com
DocumentRoot /home/user2/public_html
ScriptAlias /cgi-bin/ "/home/user2/public_html/cgi-bin/"
ServerAdmin whoever@anothersite.com
CustomLog /var/log/apache/vhost/www.anothersite.com.log combined
</VirtualHost>
#
# Give all users a cgi-bin
#
<Directory /home/*/public_html/cgi-bin>
AllowOverride None
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
Permissions are as follows:
public_html and subdirs are chmod 755
files are chmod 644
files in /cgi-bin are chmod 755
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Name based Virtual Hosting [Resolved]
Posted by Marco Bascietto <in...@bask.it>.
Thank you to Rich and David. I can access local web sites from my
browser now.
--
marco
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Name based Virtual Hosting
Posted by Rich Bowen <rb...@rcbowen.com>.
On Fri, 19 Mar 2004, Marco Bascietto wrote:
> Hello all,
>
> I am having a very trivial problem with NMVH. Apache is a rather new
> land for me and I can't figure out what I am doing wrong, even after
> reading FAQ and manuals.
> Basically I want to set up 2 NMVH to make apache point to 2 sites I have
> on my local machine.
> What I have done:
> 1. added the domains www.foo1.com and www.foo2.com to the hosts file, it
> now looks like this:
> 127.0.0.1 localhost.localdomain localhost www.foo1.com www.foo2.com
>
> 2. added 2 VH to httpd.conf:
> NameVirtualHost http://localhost:80
> <VirtualHost http://localhost>
> ServerName www.foo1.com
> DocumentRoot /var/www/html
> </VirtualHost>
> <VirtualHost http://localhost>
> ServerName www.foo2.com
> DocumentRoot /home/bask/documents/sites/foo2
> </VirtualHost>
This syntax for your vhosts is invalid. The argument to NameVirtualHost
and to <VirtualHost> is the address of the server, not the URL:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName www.foo1.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.foo2.com
DocumentRoot /home/bask/documents/sites/foo2
</VirtualHost>
> 3. called both http://www.foo1.com and http://www.foo2.com from the
> browser. They both point to /var/www/html, the DocumentRoot of the first VH.
> The question is: how can I activate the second VH?
Use the syntax above.
> And secondly, when the second VH will work:
> a. what kind of file permissions should I give to its DocumentRoot? the
> same owner:group as defined in httpd.conf?
The files need to be readable by that user, and the directory +x
(searchable) by that user. You don't want it owned by, or writeable by,
that user.
--
Nothing is perfect, certainly not me
Success to failure, just a matter of degrees
Working at perfect got me down on my knees
(Working at perfekt - Geddy Lee)
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org