Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Apache 2 Virtual Hosts

  1. #1
    Join Date
    Oct 2010
    Location
    Cape Town, South Africa
    Posts
    58

    Default Apache 2 Virtual Hosts

    Hey.

    I need to set up virtual hosts on my apache server. I am new to this and have spent the last 3 days trying to find an online tutorial on how
    to create one under opensuse. Could anyone please help with either a link or an explanation?

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,925
    Blog Entries
    2

    Default Re: Apache 2 Virtual Hosts

    Quote Originally Posted by Kyluke View Post
    Hey.

    I need to set up virtual hosts on my apache server. I am new to this and have spent the last 3 days trying to find an online tutorial on how
    to create one under opensuse. Could anyone please help with either a link or an explanation?
    Like most other things in openSUSE, open YAST.
    You'll find a configuration applet that's installed most times any Service (ie Server type application) is installed, and in this case it'll configure your Virtual Hosts as well as many other things.

    HTH,
    Tony

  3. #3
    Join Date
    Oct 2010
    Location
    Cape Town, South Africa
    Posts
    58

    Default AW: Re: Apache 2 Virtual Hosts

    Yeah thanks but I need someone to explain how to actually set one up.

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,925
    Blog Entries
    2

    Default Re: AW: Re: Apache 2 Virtual Hosts

    Quote Originally Posted by Kyluke View Post
    Yeah thanks but I need someone to explain how to actually set one up.
    The YAST applet will set up any number of Virtual Hosts.
    Is your question instead you don't understand what a Virtual Host is, how a Virtual Hosts can share the same IP address and what are the restrictions/advantages?

    Tony

  5. #5
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: AW: Re: Apache 2 Virtual Hosts

    Kyluke, the apache2 documentation is here:

    Apache Virtual Host documentation - Apache HTTP Server

    It includes some examples. When you get stuck do not hesitate to ask back here, stating what you did so far and what does not work as expected.
    Technology is 'stuff that doesn't work yet.' -- Bran Ferren

  6. #6
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: AW: Re: Apache 2 Virtual Hosts

    To get you started, this is what works for me: In /etc/apache2/httpd.local.conf I have close to the end:

    Code:
    # Set up virtual hosts
    NameVirtualHost 62.2.xxx.xx:80
    NameVirtualHost 192.168.1.10:80
    Include /etc/apache2/vhosts.d/*.conf
    Make sure that this local configuration file is included. In /etc/sysconfig/apache2 check that this is set:

    Code:
    APACHE_CONF_INCLUDE_FILES="/etc/apache2/httpd.local.conf"
    There are two sets of virtual hosts in my configuration. One for the outside and another one for the LAN users. The configuration files in /etc/apache2/vhosts.d/mydomain.conf start like this:

    Code:
    # VirtualHost template mydomain.conf
    # Note: to use the template, rename it to /etc/apache2/vhost.d/yourvhost.conf.
    # Files must have the .conf suffix to be loaded.
    #
    # See /usr/share/doc/packages/apache2/README.QUICKSTART for further hints
    # about virtual hosts.
    #
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for requests without a known
    # server name.
    #
    <VirtualHost 62.2.xxx.xx:80 192.168.1.10:80>
        ServerAdmin admin@mydomain.com
        ServerName www.mydomain.com
        ServerAlias mydomain.com
    
        # DocumentRoot: The directory out of which you will serve your
        # documents. By default, all requests are taken from this directory, but
        # symbolic links and aliases may be used to point to other locations.   
        DocumentRoot /srv/www/htdocs/mydomain
    
        # don't loose time with IP address lookups
        HostnameLookups Off
    
        # needed for named virtual hosts
        UseCanonicalName On
    
        #
        # This should be changed to whatever you set DocumentRoot to.
        #
        <Directory "/srv/www/htdocs/mydomain">
              (((your configuration stuff here)))
        </Directory>
    
    </VirtualHost>
    Please note that this is still on an openSUSE 11.2 server, but I do not think that the basic configuration had any relevant changes.
    Technology is 'stuff that doesn't work yet.' -- Bran Ferren

  7. #7
    Join Date
    Oct 2010
    Location
    Cape Town, South Africa
    Posts
    58

    Default AW: Re: AW: Re: Apache 2 Virtual Hosts

    Thanks vodoo. I have been trying to get it to work since you posted this but still having trouble. I still don't quite understand how to set it up.
    I understand what a virtual host is etc and what I would like to set up is a name based virtual host. I have followed the instructions on the apache site but it seems the config files are in different locations or something.

  8. #8
    Join Date
    Oct 2010
    Location
    Cape Town, South Africa
    Posts
    58

    Default AW: Re: AW: Re: Apache 2 Virtual Hosts

    Okay I got my virtual hosts set up. My next question is.
    How do I access them for development using localhost?
    The first one works and I know it should always pick the first one but how do I access the 2nd one?

  9. #9
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: AW: Re: AW: Re: Apache 2 Virtual Hosts

    Assuming you went for name virtual hosts, you have to address them using aliased domain names. Simplest way is to add aliases for 127.0.0.1 in /etc/hosts:

    127.0.0.1 localhost virtual1 virtual2 virtual3

    and so on. Then in the browser you have to use http://virtual1/ and so on.

  10. #10
    Join Date
    Oct 2010
    Location
    Cape Town, South Africa
    Posts
    58

    Default AW: Apache 2 Virtual Hosts

    Thanks guys it's all up and running now .
    Last question. How do I access these different servers from outside of my network? ie. Over the internet.
    I only use my IP address to connect btw.

Page 1 of 2 12 LastLast

Posting Permissions

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