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 [email protected]

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

This config works without problem

<VirtualHost *>
    ServerName collab
    ServerAdmin [email protected]

    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>
1

2 Answers 2

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
1
  • 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. Apr 17, 2013 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
1
  • 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 Apr 17, 2013 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .