Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, Would like to ask how to configure apache2 to host multiple website and how to set it as the main website without displaying the folder: Code: /www/main/index.html = http://www.domain.com/index.html ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    4

    APACHE2 - Virtual Hosts


    Hi,

    Would like to ask how to configure apache2 to host multiple website and how to set it as the main website without displaying the folder:

    Code:
    /www/main/index.html  =  http://www.domain.com/index.html
    instead of this

    Code:
    http://www.domain.com/main/index.html
    and add more websites

    Code:
    /www/site2/index.html  =  http://www.domain.com/site1/index.html
    Thank you in advance,
    Raleigh

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    the easiest way (probably the best also) is to setup your names all with the same ip,
    ip = 1.2.3.4
    server1
    server2
    server3
    server4

    at this point all the names should resolve to the same place on your apache. then use name based virtual hosts - Google Search

    you can also search for name based virtual hosts in this forum because I know I have posted lots of help on this subject.

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    19
    This is an excerpt from my /etc/httpd/conf/httpd.conf

    just changed domains and port numbers for security.

    this is so I can go to my mythweb config without going to http://www.mydomain.com/mythweb instead go to http://myth.mydomain.com:8040

    Code:
    NameVirtualHost *:8040
    NameVirtualHost *:8041
    NameVirtualHost*:8042
    
    <VirtualHost *:8040>
    DocumentRoot /var/www/html/mythweb
    ServerName myth.mydomain.com
    </VirtualHost>
    
    <VirtualHost *:8041>
    DocumentRoot /var/www/html/ampache/
    ServerName ampache.mydomain.com
    </VirtualHost>
    
    <VirtualHost *:8042>
    DocumentRoot /var/www/html/aphrodite/
    ServerName aphrodite.mydomain.com
    </VirtualHost>

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2008
    Posts
    4
    Thanks jledhead and SoX2000 for your reply.

    SoX2000,

    How about for the main site, http://www.mydomain.com?

    So it could have 4 sites
    Thanks again in advance

  6. #5
    Just Joined!
    Join Date
    May 2008
    Posts
    19
    I see.

    The document root for the main site http://www.mydomain.com is /var/www/html/ so anything under that directory is accessible by just adding the directory name to the end of the domain name. /var/www/html/mythweb is accessible by http://www.mydomain.com/mythweb.

    If you wish to rename the url without changing the directory name then you can set that in your document root

    Code:
    <VirtualHost */MyTV>
    DocumentRoot /var/www/html/mythweb
    ServerName www.mydomain.com
    </VirtualHost>
    Gives you access to /var/www/html/mythweb by typing http://www.mydomain.com/MyTV

  7. #6
    Just Joined!
    Join Date
    May 2008
    Posts
    4
    Ok, but what if the main website is configured and needs to be in a directory other than html?

    /var/www/html/myweb

    and needs to be access like this

    http://www.mydomain.com/

    Thank you so much in advance

    Raleigh

  8. #7
    Just Joined!
    Join Date
    May 2008
    Posts
    19
    I would solve this at the DNS not the webserver.

    IP being 82.12.34.56


    /var/www/html/site1/ accessible by http://82.12.34.56/site1 or www.mydomain1.com
    /var/www/html/site2/ accessilble by http://82.12.34.56/site2 or www.mydomain2.com

    or you chould have

    Code:
    <VirtualHost *>
    DocumentRoot /var/www/html/mythweb
    ServerName www.mydomain.com
    </VirtualHost>
    This I think should point www.mydomain.com to /var/www/html/mythweb but it may cause problems for any other sites you're running at the same time and wouldn't recommend it.

  9. #8
    Just Joined!
    Join Date
    May 2008
    Posts
    4
    Thank you so much for all the info, I will try all of these.

    Raleigh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •