#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171

    Visrtual host not working.


    Hi;

    Trying to set up a virtual host but it is not working for some reason! Can you see what is wrong?

    Thank you.

    Code:
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            ServerName test_server
            DocumentRoot /var/www/daryl_test_website
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/daryl_test_websiteTimeout, server not responding.             Options Indexes FollowSymLinks MultiViews
    Behnam-Jazayeris-MacBook-Pro:~ pmdg3$ 
                    Order allow,deny
                    allow from all
            </Directory>
    
            ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
            <Directory "/usr/lib/cgi-bin">
                    AllowOverride None
                    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                    Order allow,deny
                    Allow from all
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
    
            # Possible values include: debug, info, notice, warn, error, crit,
            # alert, emerg.
            LogLevel warn
    
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    /etc/hosts
    Code:
    127.0.0.1       localhost
    119.9.42.203    test_server
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    2401:1801:7800:0101:4589:c6a2:ff18:0f7e behnam
    10.176.3.55     behnam
    119.9.42.203    behnam
    Code:
    root@behnam:~# cd /var/www
    root@behnam:/var/www# ls -la
    total 36
    drwxr-xr-x  5 root   root 4096 Oct 18 01:08 .
    drwxr-xr-x 14 root   root 4096 Oct  9 06:18 ..
    drwxr-xr-x  2 root   root 4096 Oct 18 01:10 daryl_test_website
    -rwxr-xr-x  1 behnam root   49 Oct 14 10:20 goh.txt
    -rwxr-xr-x  1 behnam root   43 Oct 14 10:19 goh.txte
    -rw-r--r--  1 root   root  373 Oct  9 23:11 .htaccess
    -rwxr-xr-x  1 root   root   35 Oct 12 10:16 index.php
    drwxr-xr-x  2 behnam root 4096 Oct 12 09:19 root_folder
    drwxr-xr-x  2   1003 1004 4096 Oct 12 09:19 root_folder2
    root@behnam:/var/www# cd daryl_test_website/
    root@behnam:/var/www/daryl_test_website# cat index.php
    <?php echo 'hi';?>
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,119
    Rep Power
    9398
    Works for me.
    Code:
    GET / HTTP/1.1
    Host: test_server
    Connection: close
    
    
    HTTP/1.1 200 OK
    Date: Fri, 18 Oct 2013 04:32:18 GMT
    Server: Apache/2.2.22 (Ubuntu)
    X-Powered-By: PHP/5.4.6-1ubuntu1.3
    Vary: Accept-Encoding
    Content-Length: 2
    Connection: close
    Content-Type: text/html
    
    hi
    So how is it not working?
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by requinix
    Works for me.
    Code:
    GET / HTTP/1.1
    Host: test_server
    Connection: close
    
    
    HTTP/1.1 200 OK
    Date: Fri, 18 Oct 2013 04:32:18 GMT
    Server: Apache/2.2.22 (Ubuntu)
    X-Powered-By: PHP/5.4.6-1ubuntu1.3
    Vary: Accept-Encoding
    Content-Length: 2
    Connection: close
    Content-Type: text/html
    
    hi
    So how is it not working?
    I am trying to get to: http://119.9.42.203/test_server
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    the Server Name [test_server] is supposed to work in place of the IP address [119.9.42.203], not be appended to it.
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by DonR
    the Server Name [test_server] is supposed to work in place of the IP address [119.9.42.203], not be appended to it.
    HI;

    Then how can you access it? I want it to be accessible from every computer anywhere. Like a website.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    then you need to use a fully qualified domain name, like [test_server.example.com] as your Server Name and then access it using that Server Name.
  12. #7
  13. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by DonR
    then you need to use a fully qualified domain name, like [test_server.example.com] as your Server Name and then access it using that Server Name.
    So I MUST buy a domain name to do this, right?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    If you want ANYONE to be able to access it from ANYWHERE, then, you will need a domain to go with that hostname.
    As far as whether you NEED to buy a domain, that is not "absolutely" necessary.
    You can sign up at one of the free dynamic domain places like dynu.com, no-ip.com, freedns.afraid.org and setup your "test_server" hostname with one of their free domainnames and point the A record for it to your 119.9.42.203 IP address, then, enter that full domainname into your VirtualHost Server Name.
  16. #9
  17. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by DonR
    If you want ANYONE to be able to access it from ANYWHERE, then, you will need a domain to go with that hostname.
    As far as whether you NEED to buy a domain, that is not "absolutely" necessary.
    You can sign up at one of the free dynamic domain places like dynu.com, no-ip.com, freedns.afraid.org and setup your "test_server" hostname with one of their free domainnames and point the A record for it to your 119.9.42.203 IP address, then, enter that full domainname into your VirtualHost Server Name.
    Hey thank you for helping

    I think first step is to get my head arund /etc/hosts file.

    Here I read
    One of the IP addresses for Yahoo is 216.109.118.69. If we wanted to map Google to that IP address we would add an entry into our HOSTS file as follows: 216.109.118.69 www.google.com
    On my Mac's host file located in /etc/hosts if I add this:
    Code:
    127.0.0.1    www.yahoo.com
    Does this mean if I go to www.yahoo.com it should actually go to 127.0.0.1? It still shows me yahoo in Firefox!That's what I get from article above but it is not happening, what is not working? I am assuming that I don't need to restart any services.

    edit:
    Maybe this helps
    Code:
    bash-3.2# ping www.yahoo.com
    PING www.yahoo.com (127.0.0.1): 56 data bytes
    64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.046 ms
    64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.111 ms
    64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.104 ms
    64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.111 ms
    64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.101 ms
    64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.105 ms
    64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.119 ms
    64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.064 ms
    64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.145 ms
    So it means it should be fine and there is something in Firefoxe's cache. Cleaning cache etc has not soled it. I also believe that /etc/host is lower level and so more effective than Firefox, isn't it?

    Thank you.
    Last edited by English Breakfast Tea; October 18th, 2013 at 06:12 PM.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    There is a thing called resolv.conf (also in /etc) which will list in which order various lookups are done in. I'd guess that for hosts you have dns followed by files.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  20. #11
  21. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    /etc/hosts shoujld take precedence in resolving. You might try closing firefox completely and restarting it, firefox seems to have it's own resolver. On the computer you made the hosts file change on, try ping and see if ping resolves to 127.0.0.1 now or not.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  22. #12
  23. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by Doug G
    On the computer you made the hosts file change on, try ping and see if ping resolves to 127.0.0.1 now or not.
    Hey. Did you see post #9?
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    Ok, your computer is obeying the directives/resolution in it's local copy of /etc/hosts (as shown by your ping in post #9). That is as it should be, which leaves me wondering if I understand what the problem is?

    You are setting up a viirtual server on a local machine and wish for anyone, anywhere to access it via a hostname? If that is the case then it is the remote machines that will need to arrange their own resolution, they cannot (unless you happen to be running a name service which is authoritative for your domain qualifier) use what your machine resolves things as.

    As DonR above suggests the easiest/cheapest way to go would be to use a service that does that for you.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo