Virtual Host Not Working
I am rather new to running a webserver so please excuse me if I have missed something obvious or this is a stupid question.
I have a Redhat server running Apache and I need to host a second website on it. I tried setting up virtual hosts by editing the httpd.conf file but the new url just sends me straight to my main website.
Here is the relevant code from my httpd.conf file:
(The commas are there because it would not allow me to post urls.)
ServerAlias mywebsite,com *.mywebsite,com
Is there a step that I am missing?
A good place to look for problems is in the log file normally located in /var/log/httpd/error.log
Edit the httpd.conf and set:
Also have you restarted the httpd service
Everytime you change the conf file for httpd you need to restart the service for changes to take affect.
I have been restarting Apache after every change to httpd.conf. I do not have an error.log file but I do have files named error_log, error_log.1, error_log.2, error_log.3, and error_log.4.
All of these files are filled with "file does not exist" errors for various pages in my website. These date back further than my changes to httpd.conf.
Is there something special that I have to set up with DNS?
This configuration would not work cause the virtual hosts collide. apache simply won't know which webpage he should serve. Set up the virtual hosts correctly as explained in the documentations and you're settled.
Well the vhost config section seems fine. How is the DNS setup? DNS Server or hosts file?
Originally Posted by aRGeeBee
Can you post your full httpd.conf file
How do they collide? Can you please explain.
Originally Posted by Kloschüssel
I have my server with theplanet so I just have the domain pointed at their nameservers.
Originally Posted by jr0sco
I just revisited Apache-Dokumentation zu virtuellen Hosts - Apache HTTP Server and it seems I was wrong in my opinion. Sorry.
To test your configuration send modified header data that specify your exact host. If the server THEN does not respond with the correct website, something is broken. :-)
I.e. send along with the GET the header "Host www.newwebsite.com". If you haven't set up or got your ip already, it is enough to manually mention the entry in /etc/hosts, such that the DNS resolution points to the correct server.
Next step (if it doesn#t work) would be to check what kind of headers arrive at the server and if they are rewritten in some or the other way by the server.
You could anyway provide some ServerAlias'es in your configuration that are written without the initial www. Most servers redirect requests to www.somesite to somesite directly, thus it would not match your virtual host name.
Thank you all for your help. It turns out that the issue was due to an unusual server configuration and has since been resolved.