Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I wonder if you can help.. I have been studying for some time and I've been on a few Red Hat courses. I have sat and passed my RHCSA, and I followed by attending the RHCE course where I unfortunately failed the exam - forgot to check fstab and the server didn't boot
Anyway, I've got a re-sit booked for this Friday and I've been studying for the couple of weeks I've been back to prepare myself.
So, that's my background.. now for my question.
I'm looking at Apache Virtual hosts, and while I have it working I am intrigued by something.. I began by installing httpd, created a simple test index.html file and put it into /var/www/html, did the usual and it works fine.
I then looked at a virtual host, I configured the virtual host as follows in /etc/httpd/conf/httpd.conf:
However, the original http://server.example.com also displays the virtual.example.com web page. Now from reading a little more of the config file, it does say that the first virtual host will be the first to respond to everything if the host does not match a recognised virtual host.
I was able to fix this by amending the virtual host section of the httpd.conf file to look like this:
No, it doesn't, if you changed the test page on the guest server, it wouldn't change the page on the host server. Part of your confusion is your use of "host" as both a designation for a server running Apache and a server running a virtual sandbox where one or more "guests" are operating. The guest Apache servers versus the host Apache server.
The reason what you're doing isn't on the test is you'll only find someone doing that when working in a "test" virtual environment (as opposed to the production virtual environment) and then exceedingly rarely because it's not really important how your workstation would run the web app or site, it's only important how the guest servers are running it. In fact, I've never even turned the Apache web server built into my workstation on, the app server or site server is a guest server, the host servers (or nodes) primarily just run the sandbox and the workstations primarily just monitor and interact with the sandbox or the guests.
But my question is more, when the Apache Configuration looks at the config file for virtual hosts (at the bottom of the config file) - should it then ignore the main config (the document root outlined in the main part of the file) and look solely at the virtual host section, meaning you've got to re configure the 'main' webpage as a virtual host it's self?
Jon, I've never taken a Red Hat test, so what Red Hat is telling you is an open question in my mind. If you have a question about what's on the test, you should probably wait for one of the people who've taken it to straighten you out because I can't tell you what's on the test. I'm concerned I'm going to confuse you here and I don't want to do that.
I've got it working this way.
I suspect what you've done is configure the host apache server to accept http requests for both the www.server.com domain and the www.virtual-server.com while not configuring the guests servers to do much of anything at all. Their configuration files are not on the host machine, they are inside the shared data store that your host machine can only access by accessing the guest servers and editing the files.
Although I have sat the exam, I'm not asking for help with a particular question. I would never discuss the exam questions and I wouldn't ask for advice regarding a particular question. When we sit Red Hat exams we sign an NDA agreeing never to discuss this exam content.. I would never do this and I would'nt expect anyone else to.. it just devalues our certifications if the exams are made easy by people discussing the content. I think agree, that none of us want this.
I'm just trying to make sure I understand this stuff fully to give me the best chance of passing the exam, but more importantly so that I fully understand it for me!
I still think we're on different pages here.. I'm not talking about multiple server or virtual instances. I have one server, with one apache config file. This server will provide access to multiple websites from the same IP Address.
If the request come from http://virtual.example.com apache checks to see if there is a virtual host configured in httpd.conf associated with that domain, and if there is it will deliver the website associated with virtual.example.com... in this case:
This is working and without a problem. If I navigate locally to http://virtual.example.com I can see the content of index.html stored in /www/virtual.
No problem here.
If I turn off Virtual hosts by commenting out the line: NameVirtualHost *:80 then the default website stored in /var/www/html will be displayed when I navigate to http://server.example.com but when I navigate to http://virtual.example.com nothing is displayed (we'd expect this)...
But then I turn on Virtual hosts by uncommenting the line NameVirtualHost *:80, and add the above mentioned virtual host to the configuration file, I have to then add another virtual host for the default site located within /var/www/html.. it appears to not be recognised form the default configuration.
So I guess in essence my questions is, does the virtual host configuration override the default configuration and therefore the contents of the default document root are not looked at unless it is specified within a virtual host at the bottom of httpd.conf.
I got the impression that you were referring to Host and Guest OS's?
OK, Sorry, now I get it... you're talking about a virtual domain, not a virtual server....
There's nothing actually virtual about a virtual domain,it's just an alias. The reason they display the same web page is they have the same document root. Point the document root on the first domain to /var/www/example.com/html and the second to /var/www/virtual.example.com/html/ -after you've created the directories and populated them, give each a different index and you'll get the result your looking for.
Hope that helps.
Last edited by dijetlo; 06-01-2014 at 05:59 AM.
Reason: Standard Practice
Sorry Jon, we're about 1 question behind each other at this point....
does the virtual host domain configuration override the default configuration
No, if you dug a little deeper into Apache configuration you'd realize all your really doing at this point is binding domains for a single Apache server, it runs on a single configuration (it loads 1 set of modules, for example).
I don't know why you had to list it twice to work, I've never had that problem.
when I add a different virtual site, looking for example /www/virtual.. the config forgets that it also has a site at /var/www/html
Oh, it's because when you added the second domain they both became virtual domains from the servers point of view.Also you have the virtual domain not as a domain but as a sub domain by using the x.y.com format.
Yeah except avoid that www.somedomain.com and the www.jon.somedomain.com thing. That's not a different domain as far as the servers are concerned, it a subdivision of one domain. Make sure you use root domain names and you should be fine.
Edit: One last suggestion and I'll stop pestering you.
If I have to talk about the machine that has the webserver running on it that hosts a virtual domain, I don't ever call it a virtual host. That means something else entirely these days. I'd call it the host for the virtual domain. If you call it a virtual host you'll confuse the heck out of people.
Good luck, you appear to be doing fine in your preparation
A host for a virtual domain? I am sorry dijetlo but I think you may have been given some bad information. This has nothing to do with sub domain, domains, or virtualization.
Johnnybinthemix, to answer your question...
When you use Name-based virtual hosts, the first defined virtual host acts as a catch-all (or default host) for ALL hostnames that 1) resolve to the server and 2) do not have their own virtual host entries. You should always define a default virtual host that points to your server to act as a catch-all if you have multiple domains that resolve to the server's IP (maybe for different services), but lack a virtual host for each domain (since not all domains may need web services).
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each <VirtualHost> section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a <VirtualHost> container and list it first in the configuration file.
I am sorry dijetlo but I think you may have been given some bad information
No, that's basically what I was trying to explain to him, without being concerned about a "Default" virtual domain since he doesn't have a real domain, as is evidenced by his example.com reference. You're overthinking what he did, he's not a server in the example.com domain serving internal pages on the default domain while hosting a virtual domain externally ( a common configuration), he's emulating a web server that doesn't serve web pages on it's own domain (an internet web server, for example, without an inward facing port). He doesn't want to involve his domain settings because if you actually walked up to the machine and typed $HOSTNAME into the terminal it might say somethng like "D1QW8UHU.nodenet.pri".
Also, the correct term to use for Apache Virtual Host entries are "virtual hosts". This has nothing to do with a Virtualization, virtual machine servers, virtual machine guests, etc.
Apache can call it what they like, the virtual host in the modern IT environment is the machine hosting guest machines virtually, not a server answering more than one doorbell. That's a virtual domain server or more commonly the "the web server". You need to remember Jon prefaced the conversation with "I'm retaking my RHEL exam" which indicates he needs to get comfortable with how RHEL assigns nomenclature to this stuff, not how Apache does it.