Results 1 to 10 of 12
I've Googled this thing for days and can find many instances of others having this same problem, but cannot find a solution that works for me. The solutions always say ...
- 03-09-2009 #1
Apache2: second virtual host resolves to first virtual host's index.html
I've Googled this thing for days and can find many instances of others having this same problem, but cannot find a solution that works for me. The solutions always say to set up my virtual servers like I have them below. I have two domains with DNS resolving to the same IP address of my LAMP server. Here is the configuration from sites-enabled:
Also in sites-enabled is file 000-default:Code:<VirtualHost *> DocumentRoot /website_one <Directory "/website_one"> allow from all Options +Indexes </Directory> ServerName website_one.com </VirtualHost> <VirtualHost *> DocumentRoot /var/www/wordpress <Directory "/var/www/wordpress"> allow from all Options +Indexes </Directory> ServerName website_two.com ServerAlias website_two.com </VirtualHost>
I have tried using "123.456.789.100:80" in the VirtualHost field of both instead of '*' but that gives me "server not found" on each.Code:NameVirtualHost 123.456.789.100:80
With the above configuration, website_one works perfectly. When I try to reach the second, doing in Firefox: "http://website_two.com" it should show me website_two which is wordpress. It doesn't. Rather, it takes me to the same webpage as website_one. I know wordpress is working because up till now, I've always accessed it as a page from website_one but now I want it to give it its own domain.
Why am I getting website_one's index.html when trying to reach website_two instead of website_two's index.php for wordpress? This is my first attempt at setting up virtual hosts with Apache so be gentle with me...
Any help or insight appreciated.
- 03-09-2009 #2
can you get the server log messages. and what linux are you using? are your selinux and permissions ok?
- 03-09-2009 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 49
This sounds similar to an issue I have seen before which turned out to be because they were using <virtualhost *> rather than <virtualhost website_one.com:*>
So you could either change these tags or add the vhost names into your /etc/hosts file which sould fix the issue.
- 03-09-2009 #4
I run Gentoo, so YMMV with this solution (directories could be different, you may have symlinks in a directory to enable vhosts, etc... but this configuration has worked on several distros, including debian. Just adapt it as necessary).
I leave my default vhost as the default, and only run websites from my home directories. Each virtual host is in a different file.
Each one uses the layout here:
And that is it. That is all I do to have different vhosts point to different directories. Just replace gruven.sytes.net and the root directory to adapt to your system.Code:<VirtualHost *:80> ServerName gruven.sytes.net DocumentRoot /home/don/public_html/gruven ServerAlias gruven.sytes.net </VirtualHost>
*edit
Not sure if this makes a difference, but the naming scheme for each of my virtual host files is:
Just change the number to increase with each one, and change the name (gruven.sytes.net) to reflect the domain you are hosting in it. I put this in /etc/apache2/vhosts.d. I also have default_vhosts turned on in my apache config file.Code:01_gruven.sytes.net_vhost.conf
- 03-09-2009 #5
- 03-09-2009 #6Just Joined!
- Join Date
- Dec 2006
- Posts
- 5
I've had this same problem. My solution was checking in my listen.conf file and making sure you had <VirtualHost *:80> entries for all variations of your domain name, such as:
<VirtualHost *:80>
ServerName host-one.com
DocumentRoot /home/somefile
DirectoryIndex index.html, etc...
</VirtualHost>
<VirtualHost *:80>
ServerName www.host-one.com
DocumentRoot /home/somefile
DirectoryIndex index.html, etc...
</VirtualHost>
And so forth... I hope that helps you, I know how frustrating your situation is
- 03-10-2009 #7
That would be annoying. I thought that the point of virtual hosts was to basically put the settings in one file and apache would handle the rest. Basically, you have to put them in two places doing that, and it seems pointless to me. Just my opinion though.
Different distros do it different ways though.
- 03-10-2009 #8Just Joined!
- Join Date
- Dec 2006
- Posts
- 5
- 03-10-2009 #9
I looked around my folders of apache configs, and I couldn't even find a listen.conf. This just goes to show you that different distros do some things extremely different.
It probably would have helped though if we would have asked Dapper Dan what version he was running of apache, because they change their config's around in versions too.
I know in Debian all you have to do is make a symlink from /etc/apache2/vhost-config-folder to /etc/apache2/vhost-enabled or something very similar.
Let me ask you dalrq79, does Suse have a yast module to configure apache? And if so, does it change your listen.conf? Just curious so that maybe we can help others that have vhost problems. I know I do when I go do different distros sometimes.
I usually just go to the apache website and create a barebones vhost config file for each site, and then just add and subtract things until it works. I have found that simple is usually better.
In Gentoo, we have /etc/apache2/httpd.conf, and /etc/conf.d/apache2 for config files. My vhosts go in /etc/apache2/vhosts.d.
We should start a apache sticky with the config files and vhosts howto's for each distro. hmmm....
- 03-10-2009 #10Just Joined!
- Join Date
- Dec 2006
- Posts
- 5


Reply With Quote
