Apache Name Based VirtualHost Example




+ Reply to Thread
Results 1 to 4 of 4

Thread: Apache Name Based VirtualHost Example

  1. #1
    Meer is offline Senior Member
    Join Date
    Sep 2010
    Posts
    179
    Feedback Score
    0

    Apache Name Based VirtualHost Example



    Q. Can you give or specify an example for Apache name based VirtualHost feature under CentOS/ RHEL / Fedora Linux?

    A. The term Virtual Host refers to the practice of maintaining more than one web site on one Apache machine or server.
    The NameVirtualHost directive is a required directive if you want to configure name-based virtual hosts.
    With the NameVirtualHost directive you specify the IP address on which the server will receive requests for the name-based virtual hosts. This will usually be the address to which your name-based virtual host names resolve.
    Apache 2 Name based virtualhost Configuration

    For example if your IP address is 203.54.2.5. Set it as follows in httpd.conf file:
    # vi /etc/httpd/conf/httpd.conf
    Set NameVirtualHost as follows:
    NameVirtualHost 203.54.2.5:80
    Let us see how your virtual host entry looks for two domains called theos.in and nixcraft.com . Code for theos.in domain:
    <VirtualHost theos.in/>
    ServerAdmin webmaster@theos.in
    DocumentRoot /var/www/theos.in
    ServerName theos.in
    ServerAlias www.theos.in
    ErrorLog /var/logs/httpd/theos.in/error_log
    CustomLog /var/logs/httpd/theos.in/access_log common
    </VirtualHost>

    Code for nixcraft.com domain:
    <VirtualHost nixcraft.com/>
    ServerAdmin webmaster@nixcraft.com
    DocumentRoot /var/www/nixcraft.com
    ServerName nixcraft.com
    ServerAlias www.nixcraft.com
    ErrorLog /var/logs/httpd/nixcraft.com/error_log
    CustomLog /var/logs/httpd/nixcraft.com/access_log common
    </VirtualHost>

    Save and close the file. Restart Apache:
    # /etc/init.d/httpd restart
    Make sure both domains theos.in and nixcraft.com points to (A address) 203.54.2.5. Also make sure you create /var/logs/httpd/domain-name directories and point ftp user directory to appropriate /var/www/domain-name directory.
    Virtual Hosts and IP addresses

    IPv4 has limited set of IP address. If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations use only name-based virtual hosts so the server doesn't need to worry about IP addresses using the asterisks in the config file as follows:
    NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/usr/local/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "/var/log/dummy-host.example.com-error_log" CustomLog "/var/log/dummy-host.example.com-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/usr/local/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "/var/log/dummy-host2.example.com-error_log" CustomLog "/var/log/dummy-host2.example.com-access_log" common </VirtualHost>

  2. #2
    ogt69gt69 is offline Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Feedback Score
    0
    thanks man

  3. #3
    thenyou5 is offline Junior Member
    Join Date
    Aug 2011
    Posts
    1
    Feedback Score
    0
    Great tut

  4. #4
    TravEYE is offline Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Feedback Score
    0
    Thanks! Looks great!

+ Reply to Thread

Visitors found this page by searching for:

name based virtualhost

apache2 vhost seo

sample virtual host apache2 for SEO

link to all name based virtual hosts

name based virtual hosting cname

apache name host

apache2 name based virtual host examples

namevirtualhost sample

Apache enable name based virtual hosts

virtualhost sample

vhost example www. apache var/logs

virtual host seo link

sample apache vhost seo www

ip based virtual hosting apache#p

vhost name-based examples

virtual host example

apche2 examples virtualhosts cnames

why i can not set up IP-base virtual hosts fedora

apache2 name based vhost

Posting Permissions

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