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: Vhost
Author
Ang3lus



Joined: 02 Aug 2010
Posts: 18

PostPosted: Sun 12 Sep '10 12:08    Post subject: Vhost Reply with quote

Hi

I want to create 2 name based virtual host on single server
for example: the first hostname is: site1.com
the second one is: site2.com
i read apache2 doc and i tried to follow steps correctly
However, when i try to access any site via browser it gave me error page: Server not found

===============
from httpd.conf file:

ServerName my servername.net:80
ServerAdmin admin@localhost
DocumentRoot "/home/www"
NameVirtualHost *:80

<VirtualHost *:80>
ServerName site1.com
DirectoryIndex index.html
DocumentRoot "/home/site1"
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
DocumentRoot "/home/site2"
</VirtualHost>


I can't access : site1.com or site2.com via browser
only i can access main server


there are something wrong with these configurations

from apache documentation . i can't understand this point:
Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames


any help would be appreciated
thanks
Back to top
glsmith
Moderator


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

PostPosted: Sun 12 Sep '10 18:51    Post subject: Reply with quote

First vhost needs to be a minor duplicate of the main host (servername.net)

So, for the first vhost

<VirtualHost _default_:80>
DocumentRoot "/home/www"
</VirtualHost>

with site1.com and site2.com vhosts below it

It's explained in the name based docs under the heading "Main host goes away" but is known to show itself differently for different people. In your case main host shows the vhosts don't.
Back to top
Ang3lus



Joined: 02 Aug 2010
Posts: 18

PostPosted: Tue 14 Sep '10 7:23    Post subject: Reply with quote

thanks for your replay glsmith

i figured out my problem. i need to add entries to dns

there is another possible way to achieve virtual host without dns entries cause iam not run sever as root
Back to top
glsmith
Moderator


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

PostPosted: Tue 14 Sep '10 17:54    Post subject: Reply with quote

if you are just running it locally use the hosts file, not sure where it is in *nix but I'm sure someone here knows. If you want it to answer to the outside world, dns or a lot of IPs is going to be needed. Server should not need to be run as root in either case. Never run it as root.
Back to top
James Blond
Moderator


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

PostPosted: Tue 14 Sep '10 23:31    Post subject: Reply with quote

glsmith wrote:
not sure where it is in *nix but I'm sure someone here knows.

/etc/hosts

On most system
Code:

sudo nano /etc/hosts


Different to windows, if you wanna use more than one hostname to 127.0.0.1 add them in a row
e.g.
Code:

127.0.0.1 computername localhost vhost1.local vhost2.local
Back to top
Ang3lus



Joined: 02 Aug 2010
Posts: 18

PostPosted: Thu 16 Sep '10 7:00    Post subject: Reply with quote

thanks for your help guys
it works fine locally from hosts file


Mr. Green another question:

if i have Document root path for example is: /var/home/htdocs
and the server name for exampe is: apacheserver.net


is possible to add link to my server as following:
htdocs.apachesever.net


sorry for bad explain i am just beginner


thanks
Back to top
James Blond
Moderator


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

PostPosted: Thu 16 Sep '10 11:39    Post subject: Reply with quote

You think of a vhost for each user or just an alias for that domain?
Back to top
Ang3lus



Joined: 02 Aug 2010
Posts: 18

PostPosted: Fri 17 Sep '10 16:22    Post subject: Reply with quote

Many thanks for you guys Mr. Green

I want to use it as alias and its work now fine Very Happy

thanks again
Back to top


Reply to topic   Topic: Vhost View previous topic :: View next topic
Post new topic   Forum Index -> Apache