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: How to host multiple websites on one server?
Author
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Tue 13 Sep '11 12:39    Post subject: How to host multiple websites on one server? Reply with quote

Hi Apachelounge, not sure if this is a apache question or perhaps something more advanced.

What i want to do is to be able to with one physical machine (server) host multiple websites using multiple different domain urls.

Lets say i am hosting one site with www.myfirstsite.com which i have the domain A records pointing to the ip of the physical webserver. Fine everything works great.

But how do i install a second website into this machine and have it being access from lets say domain number two www.myseconddomain.com?

I know that domain records do not support any / in their settings so you can't point a domain record to ipadress/subpath.

Can you setup apache with htaccess to filter "check" where the hit comes from (which domain used to reach the ip) and that way filter the incoming traffic internally?

I am very interested on how shared webservers are configured.

I am a rookie at this, thanks!
Back to top
James Blond
Moderator


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

PostPosted: Tue 13 Sep '11 12:53    Post subject: Reply with quote

All A records can point to the same IP. No subpath needed. Wink Than you can set up vhosts. By the domain name the browser sends to apache it decides which vhost to use. Notice: when you use vhost the first host (mostly localhost) from the httpd.conf disapears.

example
Code:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin info@localhost
    ServerName localhost
    DocumentRoot C:/www/localhost
    <Directory C:/www/localhost>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog logs/localhost_error.log
    LogLevel warn

    CustomLog C:/apache22/logs/localhostaccess.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin info@firstdomain.com
    ServerName firstdomain.com
   ServerAlias www.firstdomain.com
    DocumentRoot C:/www/firstdomain
    <Directory C:/www/firstdomain>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog logs/firstdomain_error.log
    LogLevel warn

    CustomLog C:/apache22/logs/firstdomain_access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin info@seconddomain.com
    ServerName seconddomain.com
   ServerAlias www.seconddomain.com
    DocumentRoot C:/www/seconddomain
    <Directory C:/www/seconddomain>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog logs/seconddomain_error.log
    LogLevel warn

    CustomLog C:/apache22/logs/seconddomain_access.log combined
</VirtualHost>
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Tue 13 Sep '11 13:01    Post subject: Reply with quote

Very nice, i am excited to try this out, thank you!
Back to top


Reply to topic   Topic: How to host multiple websites on one server? View previous topic :: View next topic
Post new topic   Forum Index -> Apache