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

Thread: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

  1. #1
    Join Date
    Oct 2013
    Beans
    20

    Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    SETUP:
    Apache/2.4.6
    Ubuntu 12.x


    I am having trouble setting up any virtual hosts on my LAN. I want to have multiple name based virtual hosts. The first example vhost i am setting up is days.com. Unfortunately, when I type that address, Apache/2.4.6 does not redirect the address to the vhost.


    Heres my days.com.conf (enabled) in /etc/apache2/sites-available:


    Code:
    <VirtualHost *:80>
            ServerName days.com
            ServerAlias www.days.com
    
    
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/zzz
    
    
            #ErrorLog ${APACHE_LOG_DIR}/error.log
            #CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    
            <Directory />
                    Options All
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    I enabled it using:
    Code:
    sudo a2ensite days.com.conf
    sudo service apache2 reload
     * Reloading web server apache2
    If I run the following command I get this response:
    Code:
    apachectl -S
    VirtualHost configuration:
    Code:
    *:80                   is a NameVirtualHost
             default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost days.com (/etc/apache2/sites-enabled/days.com.conf:1)
                     alias www.days.com
    Heres my /etc/hosts file setup:
    Code:
    #127.0.0.1      localhost
    #Virtual Hosts
    127.0.0.1       days.com www.days.com duck.dev
    days.com        days.com www.days.com
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-l   ocalnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    What am I doing wrong?

    FYI:
    The only two conf files in /etc/apache2/sites-available and /etc/apache2/sites-enabled are:
    Code:
    000-default.conf
    days.com.conf

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    Remove this line:

    Code:
    days.com        days.com www.days.com
    The hosts file is only used for ip address to host name resolution.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    Join Date
    Oct 2013
    Beans
    20

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    OK. I removed that line, but my vhost is not working yet. Here's exactly what i did:
    Removed this line from /etc/hosts :
    Code:
    days.com        days.com www.days.com
    Reloaded apache2.4.6:
    Code:
    :~$ sudo service apache2 reload
     * Reloading web server apache2                                                                                                                                                                              *
    IN my browser:
    1. Cleared cache
    2. Typed www.days.com in address field

    FYI: I also tried:
    Code:
    sudo service apache2 restart
    * Restarting web server apache2
    Last edited by vsiege2; December 12th, 2013 at 09:28 PM.

  4. #4
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    What does it say after you try to access days.com ?

    Run this after you try to access it:

    Code:
    tail /var/log/apache2/access.log
    I think that's right, I don't use Apache, so I'm not 100% sure.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  5. #5
    Join Date
    Oct 2013
    Beans
    20

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    I don't see anything get updated in the access log when I type: http://days.com or days.com or www.days.com

    The only things that appear:
    Code:
    127.0.0.1 - - [12/Dec/2013:12:14:57 -0800] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.6 (Ubuntu) PHP/5.5.6-1+debphp.org~precise+2 (internal dummy connection)"127.0.0.1 - - [12/Dec/2013:12:14:57 -0800] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.6 (Ubuntu) PHP/5.5.6-1+debphp.org~precise+2 (internal dummy connection)"
    127.0.0.1 - - [12/Dec/2013:12:14:57 -0800] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.6 (Ubuntu) PHP/5.5.6-1+debphp.org~precise+2 (internal dummy connection)"
    127.0.0.1 - - [12/Dec/2013:12:14:57 -0800] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.6 (Ubuntu) PHP/5.5.6-1+debphp.org~precise+2 (internal dummy connection)"
    127.0.0.1 - - [12/Dec/2013:12:14:57 -0800] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.6 (Ubuntu) PHP/5.5.6-1+debphp.org~precise+2 (internal dummy connection)"
    192.168.16.170 - - [12/Dec/2013:13:48:13 -0800] "GET /fake/dev/ HTTP/1.1" 200 735 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
    192.168.16.170 - - [12/Dec/2013:13:48:13 -0800] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
    192.168.16.170 - - [12/Dec/2013:13:52:46 -0800] "GET /fake/dev/ HTTP/1.1" 200 735 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
    192.168.16.170 - - [12/Dec/2013:13:52:47 -0800] "GET /fake/dev/ HTTP/1.1" 200 734 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
    192.168.16.170 - - [12/Dec/2013:13:53:42 -0800] "GET /fake/dev/ HTTP/1.1" 200 735 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

  6. #6
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    What machine are you trying to access the days.com site from?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  7. #7
    Join Date
    Oct 2013
    Beans
    20

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    Im accessing the address from another box on my LAN. Its a mac. The Ubuntu server has a static IP while everything else has a dynamic IP. I'm actually kind of amazed it's taken me this long to get this working. If I type the address of the server in, then put the relevant directory, I can see the site located in www directory.

  8. #8
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    Quote Originally Posted by vsiege2 View Post
    Im accessing the address from another box on my LAN. Its a mac. The Ubuntu server has a static IP while everything else has a dynamic IP. I'm actually kind of amazed it's taken me this long to get this working. If I type the address of the server in, then put the relevant directory, I can see the site located in www directory.
    Which machine were you modifying the hosts file on?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  9. #9
    Join Date
    Jul 2011
    Location
    Lebanon
    Beans
    10
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    what is the result of this command?

    dig days.com ?

  10. #10
    Join Date
    Oct 2013
    Beans
    20

    Re: Setting up name-based virtual hosts on Apache Apache/2.4.6 (Ubuntu 12)

    I was modifying the ubuntu server hosts file over ssh from my osx box


    DIG:

    ; <<>> DiG 9.8.1-P1 <<>> days.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44317
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0


    ;; QUESTION SECTION:
    ;days.com. IN A


    ;; ANSWER SECTION:
    days.com. 3600 IN A xx.xxx.xx.xx


    ;; Query time: 6 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Fri Dec 13 11:12:36 2013
    ;; MSG SIZE rcvd: 42
    Last edited by vsiege2; December 16th, 2013 at 11:35 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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