1

I've been battling to get a vhost config working on an internal development server at work. I have found other vhost configs in the site-available directory. For some reason, I can't see why my new vhost is not responding to any requests. All i get is a 404 statement. This is not a publicly access server so I'm not sure if that has anything to do with this. Also if I purposely add a syntactic error in my config.. apache yells at me so I know it actually being loaded. I have restarted the apache server multiple times. I don't know if it has to do with the servername at all. I just want to type in 192.168.254.35/rackapp and have apache drop me in the DocumentRoot i have chosen. Currently i can do 192.168..254.35/rack_example/public.

  • Where else should I be editing to make this work?

This is what I am trying to load

<VirtualHost *>
    ServerName rackapp
    ServerAdmin atomphson@abc.com

    DocumentRoot /var/www/rack_example/
</VirtualHost>

This config works without problem

<VirtualHost *>
    ServerName collab
    ServerAdmin ason@abc.com

    DocumentRoot /var/www/collab/

    ErrorLog /var/log/apache2/colab-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/collab-access.log combined

</VirtualHost>
user2108258
  • 303
  • 1
  • 3
  • 10
  • related : https://stackoverflow.com/questions/27152943 https://superuser.com/questions/922869 https://unix.stackexchange.com/questions/129026 https://serverfault.com/questions/425894 https://serverfault.com/questions/696164 https://serverfault.com/questions/500329 https://serverfault.com/questions/489018 https://serverfault.com/questions/42539 http://httpd.apache.org/docs/current/mod/mod_info.html http://httpd.apache.org/docs/current/invoking.html – immeëmosol Jul 19 '17 at 09:11

2 Answers2

2

Apache uses the hostname you type in your browser to select the right virtual host. If you use the IP address, it will pick the first virtual host available.

To test your virtual hosts, you should access them by their name. For this you can edit the hosts file /etc/hosts and add those two lines:

192.168.254.35 rackapp
192.168.254.35 collab

%SystemRoot%\system32\drivers\etc\hosts for Windows systems.

Then you'll be able to access http://rackapp/ or http://collab/ and test your Apache configuration.

You can also play a bit and directly send the HTTP header to your Web server:

$ echo -e "GET / HTTP/1.1\r\nHost: rackapp\r\n\r\n" | nc 192.168.254.35 80
Spack
  • 1,594
  • 13
  • 22
  • Still confused sorry..I'd like to use 192.168.254.35/rackapp as the url for a specific application on this box.. I don't want to change how the box is accessed just rather this one application or subdirectory. – user2108258 Apr 17 '13 at 19:49
1

You're confusing servername and URL here.

If you want to have 192.168.25.35/rackapp be the URL for the server, then the ServerName of the VirtualHost should be 192.168.25.35 instead of rackapp. With the setup you've got, you need to connect to the server using http://rackapp instead, and that will give you the document root you've set up for the virtualhost.

If trying to connect to http://rackapp gives you "Server not found", then you need to edit your /etc/hosts file to contain the line

19.168.25.35 rackapp
Jenny D
  • 27,358
  • 21
  • 74
  • 110
  • Thanks JD for your response. Will this work with other applications on the same box.. This box has other applications in /var/www .. I'd like to access an application on this box by writing 192.168.254.35/rackapp. Excuse my ignorance on the subject – user2108258 Apr 17 '13 at 19:41