Virtual Hosts displays the same pages
Virtual Hosts displays the same pages
Hi all,
I dont know what is going wrong on my vhost setting. I have a one IP address with hostname and a cname. So I wanted run two website on this.
test1.abc.com
test2.abc.com
test2.abc.com IN CNAME test1.abc.com
test1.abc.com IN A 192.168.1.1
Then I edited in my httpd.conf as this
ServerName test2.abc.com
DocumentRoot /var/www/html/test
After restarting the apache. in browser i can see the same page as test1.abc.com and test2.abc.com. I have different content. Any help would be appericiated.
M
I dont know what is going wrong on my vhost setting. I have a one IP address with hostname and a cname. So I wanted run two website on this.
test1.abc.com
test2.abc.com
test2.abc.com IN CNAME test1.abc.com
test1.abc.com IN A 192.168.1.1
Then I edited in my httpd.conf as this
ServerName test2.abc.com
DocumentRoot /var/www/html/test
After restarting the apache. in browser i can see the same page as test1.abc.com and test2.abc.com. I have different content. Any help would be appericiated.
M
Virtual Hosts displays the same pages
Is test2.abc.com the only configured VirtualHost? If so, that's normal behavior. The first VirtualHost Apache finds will be used for any requests to unknown/unconfigured hostnames and domains. I always configure the first vhost on servers at work to redirect people to the main company website on dedicated boxes or my work's site for shared servers.
Re: Virtual Hosts displays the same pages
The vhosts.conf file would need to read something like this:
NameVirtualHost *:80
ServerName test1.abc.com
DocumentRoot /var/www/html/test1
ServerName test2.abc.com
DocumentRoot /var/www/html/test2
------------------------------------------------------
See the output of "httpd -s" for more information.
NameVirtualHost *:80
ServerName test1.abc.com
DocumentRoot /var/www/html/test1
ServerName test2.abc.com
DocumentRoot /var/www/html/test2
------------------------------------------------------
See the output of "httpd -s" for more information.
Re: Virtual Hosts displays the same pages
here is my virtual host section looks like.
ServerName test2.abc.com
DocumentRoot /tmp/test/
I leave the default setting for test1.abc.com and just added the above section for virutal host. I still get the same pages.
M
ServerName test2.abc.com
DocumentRoot /tmp/test/
I leave the default setting for test1.abc.com and just added the above section for virutal host. I still get the same pages.
M
Re: Virtual Hosts displays the same pages
The main server is different from virtual hosts. When using vhosts, you need to configure one for every site you want to host (like jaylakes's example). Take any custom configuration from the main server (redirects, allow/deny, overrides, documentroot, logging, etc) and throw it into a vhost for test1.abc.com, then [i]/etc/init.d/httpd graceful[/i] and try again.
Re: Virtual Hosts displays the same pages
Hi all,
Do you mean leave the global setting as it is then all the custom setting dum into test1 virtual host section ? Basically two virtual server test1 (main server) and test2 right ?
would like this
NameVirtualHost *:80
ServerName test1.abc.com
ServerAdmin madal@abc.com
DocumentRoot /tmp/test1
ServerName test2.abc.com
DocumentRoot /tmp//test2
Do you have example something like what i am trying to do ?
Thanks
M
Do you mean leave the global setting as it is then all the custom setting dum into test1 virtual host section ? Basically two virtual server test1 (main server) and test2 right ?
would like this
NameVirtualHost *:80
ServerName test1.abc.com
ServerAdmin madal@abc.com
DocumentRoot /tmp/test1
ServerName test2.abc.com
DocumentRoot /tmp//test2
Do you have example something like what i am trying to do ?
Thanks
M
Re: Virtual Hosts displays the same pages
Hi
In my case virtual host dont work because of missing index.html file
Below is working solution
nano /etc/httpd/conf/httpd.conf
add the following section
NameVirtualHost *:80
ServerName centos
DocumentRoot /var/www/html/
Include /etc/httpd/vhosts.d/*.conf
Create folders
mkdir /etc/httpd/vhosts.d/
mkdir p /var/www/vhosts/rocafella/
Create vhost config
nano /etc/httpd/vhosts.d/rocafella.conf
ServerName rocafella
DocumentRoot /var/www/vhosts/rocafella/
Create test index.html
nano /var/www/vhosts/rocafella/index.html
test
service httpd restart
In my case virtual host dont work because of missing index.html file
Below is working solution
nano /etc/httpd/conf/httpd.conf
add the following section
NameVirtualHost *:80
ServerName centos
DocumentRoot /var/www/html/
Include /etc/httpd/vhosts.d/*.conf
Create folders
mkdir /etc/httpd/vhosts.d/
mkdir p /var/www/vhosts/rocafella/
Create vhost config
nano /etc/httpd/vhosts.d/rocafella.conf
ServerName rocafella
DocumentRoot /var/www/vhosts/rocafella/
Create test index.html
nano /var/www/vhosts/rocafella/index.html
test
service httpd restart
Re: Virtual Hosts displays the same pages
Hello all,
Thanks for your all replies. Finally my vhost in fact works now. here is what i had to do.
NameVirtualHost *:80
ServerName test1.abc.com
DocumentRoot "/var/www/html/"
ServerName test2.abc.com
DocumentRoot "/var/www/vhosts/seti/"
i commented the DocumentRoot that was in default. but question is how many virtual server can be setup in port 80 ?
Madal
Thanks for your all replies. Finally my vhost in fact works now. here is what i had to do.
NameVirtualHost *:80
ServerName test1.abc.com
DocumentRoot "/var/www/html/"
ServerName test2.abc.com
DocumentRoot "/var/www/vhosts/seti/"
i commented the DocumentRoot that was in default. but question is how many virtual server can be setup in port 80 ?
Madal
Re: Virtual Hosts displays the same pages
I'm not aware of any limit. I've got 206 's on a development server at work. You'll probably hit the maximum number of open file descriptors before anything else (lots of Custom/Transfer/ErrorLog directives).