Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So after many hours of wrestling with Virtual Hosting, I've managed to get one of my websites up using the virtual hosting file. I have 2 files (domain1.com & domain2.com) in /etc/apache2/sites-available/(file names). I also have them symbolically linked to /etc/apache2/sites-enabled/(file names). When I have domain1.com in sites enabled, and I browse to domain1.com, I get it. When both domain1.com and domain2.com in sites-enabled and I browse to domain1.com, I get domain2.com and cannot get to domain1.com in the browser. What am I missing?
There is one interesting piece of information that may bear on this config. The server is sitting behind a firewall with a private IP of 10.0.0.11. So I don't know if that works in to the equation or not.
billymayday:
/etc/apache2 is the apache server root
document root is usually
/var/www
with debian / ubuntu
vap16...:
the path /etc/httpd/... doesn't exist in ubuntu/debian.
That's more rather red-hat / fedora-ish
httpd.conf in /etc/apache2/ is usually empty, as the files are split up.
buee: Not sure if it's because it's missing, however in my vhost config I have at line 1 in file "default"
"NameVirtualHost *"
then followed by one <VirtualHost> block.
Other <Virtualhost> blocks are in separate files, however the default gets loaded first by being symlinked to
000-default, therefore NameVirtualHost being loaded first.
right now don't see anything wrong / missing otherwise which could cause it (unless teh DocRoot need a trailing slash, which all mine have)
Have you also tried with <directory> entries in virtualhost block?
Code:
<Directory /doc_root/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
however can't say if that's vital / necessary for multiple vhosts.
Sorry - you lost me with the bit about /etc/apache2, but then your document root is /var/www/domain1.
Can you explain what is where a bit more clearly?
Sure, I guess using different variables would be more efficient. The tutorial I was following said to create the file for the vhosts. That is stored in /etc/apach2/sites-available/vhost (vhost is the file). The contents of which are above. Then I have that symlinked to sites-enabled. Also, I have removed the symlink for 000-default. From what I understand, that won't be an issue. It's just going to pull all files from sites-enabled. The index.html files are in /var/www/(respective folders) so the html file for domain1 is /var/www/domain1/index.html. The html file(s) for domain2 is /var/www/domain2/index.html <---(This is supposed to be a wordpress blog). I hope that clears that up...probably not.
rsciw is correct in that the httpd.conf file is completely empty in my case. I'm running Ubuntu 8.04 server i386 with apache2. I tried this method as well with 0 success.
To rsciw: I have tried using the NameVirtualHost * directive but that seems to mess things up worse than they were before. I have not tried the directory directive yet, mainly because I have seen it in about 20% of the examples I've seen. I suppose I could throw that in and see if it does any good, I guess I was just searching for someone that could catch a 1 where there's supposed to be a 0 and slap me in to submission.
I think everyone else's questions were answered. I've also tried adding a number of different things in to serveralias such as *.domain2.com. But that is unsuccessful as well. If that Directory /doc_root will work, I'll give it a go. It can't get much worse.
If you are trying to use name virtual hosts, then you need the NameVirtualHost directive as I recall.
I don't know how it's done under Debian (just in case you hadn't picked that one up), but I'd try a single file with both virtual hostst defined in it and the NameVirtualHost directive at the top. it may be the order in which the files a read by apache that is causing problems.
If you are trying to use name virtual hosts, then you need the NameVirtualHost directive as I recall.
I don't know how it's done under Debian (just in case you hadn't picked that one up), but I'd try a single file with both virtual hostst defined in it and the NameVirtualHost directive at the top. it may be the order in which the files a read by apache that is causing problems.
I have tried that, in fact, it may be in there now. And I did combine the VirtualHost directives in to one file. When doing that, since the box is on a firewall, do I need to put the public IP that points to it or the private? I would assume the public. One other concern I have is, do I need to forward additional ports to the box? Right now I only have 80 but was wondering if possibly 53 is necessary as well for some reason since the requests are handled differently by DNS.
billymayday:
/etc/apache2 is the apache server root
document root is usually
/var/www
with debian / ubuntu
vap16...:
the path /etc/httpd/... doesn't exist in ubuntu/debian.
That's more rather red-hat / fedora-ish
httpd.conf in /etc/apache2/ is usually empty, as the files are split up.
buee: Not sure if it's because it's missing, however in my vhost config I have at line 1 in file "default"
"NameVirtualHost *"
then followed by one <VirtualHost> block.
Other <Virtualhost> blocks are in separate files, however the default gets loaded first by being symlinked to
000-default, therefore NameVirtualHost being loaded first.
right now don't see anything wrong / missing otherwise which could cause it (unless teh DocRoot need a trailing slash, which all mine have)
Have you also tried with <directory> entries in virtualhost block?
Code:
<Directory /doc_root/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
however can't say if that's vital / necessary for multiple vhosts.
I tried this just now and when trying to access domain1.com, I get an apache error that the URL / was not found on the server. I then tried domain2 and it pulled up but with horrible formatting and didn't look normal (it's supposed to be a wordpress site), which may be attributed to the fact that it's a PHP page and not .html. Not sure, but I can tackle that one later. This is with the following file symlinked in sites-enabled:
Code:
NameVirtualHost *
#
# domain1.com
#
<VirtualHost *>
ServerName domain1.com
ServerAlias www.domain1.com
<Directory /var/www/domain1/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
CustomLog /var/www/logs/domain1.com-access.log combined
ErrorLog /var/www/logs/domain1.com-error.log
</VirtualHost>
#
# blog.domain2.com
#
<VirtualHost *>
ServerName blog.domain2.com
ServerAlias www.blog.domain2.com *.domain2.com
DocumentRoot /var/www/blog
<Directory /var/www/blog/ >
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
CustomLog /var/www/logs/Blog.domain2.com-access.log combined
ErrorLog /var/www/logs/Blog.domain2.com-error.log
</VirtualHost>
Then I thought, maybe if I through the index.html and index.php at the end of those Directory directives, it might shake something lose. But it yielded the exact same results.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.