You are not logged in.

#1 2013-02-16 15:30:49

kensai
Member
From: Puerto Rico
Registered: 2005-06-03
Posts: 2,484
Website

Help with VirtualHost (SOLVED)

Believe my I have tried and I am frustrated. The thing is, I have set up my web server to use httpd-vhost.conf so I set up my main domain and my other domain there as follows:

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin ******@gmail.com
    DocumentRoot "/srv/http"
   ServerName myserver1.org
    ErrorLog "/var/log/httpd/myserver1.org-error_log"
    CustomLog "/var/log/httpd/myserver1.org-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin ******@gmail.com
    DocumentRoot "/home/******/http/myserver2.com"
    ServerName myserver2.com
    ErrorLog "/var/log/httpd/myserver2.com-error_log"
    CustomLog "/var/log/httpd/myserver2.com-access_log" common
</VirtualHost>

And my /etc/hosts are configured with

127.0.0.1                               localhost.localdomain   localhost
127.0.0.1                               ******.myserver1.org       ******
127.0.0.1                               ******.myserver2.com     ******
ipnumbershort                        ******.myserver1.org       ******
ipnumbershort                        ******.myserver2.com     ******
ipv6addresslong                     ******.myserver2.com      ******
ipv6addresslong                     ******.myserver1.org       ******
::1                                         localhost.localdomain   localhost

And everytime I access www.myserver2.com it shows me the content of www.myserver1.org

I mean I'm not that good at web servers they are just my hobby, but I get frustrated when I can't find a simple mistake.

Thanks in advance, please ask of any other info you need,

Eduardo Romero

Last edited by kensai (2013-02-24 14:47:44)


Follow me in: Identi.ca, Twitter, Google+

Offline

#2 2013-02-21 22:37:07

gsgleason
Member
Registered: 2012-10-08
Posts: 71

Re: Help with VirtualHost (SOLVED)

Your servername is oss-pr.com but the http host you're specifying in the browser is www.oss-pr.com, which is not the same, so it's going to the first one.

Add this to the oss-pr.com config after the ServerName:
ServerAlias www.oss-pr.com

http://httpd.apache.org/docs/2.2/mod/co … erveralias

Offline

#3 2013-02-22 09:56:05

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Help with VirtualHost (SOLVED)

You can/should leave the ServerName as is and add a ServerAlias

ServerAlias www.server.com

Also, I add the www.server.com to my /etc/hosts

And change the

<VirtualHost *:80>
to
<VirtualHost server.com:80>

Last edited by hunterthomson (2013-02-23 04:08:10)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#4 2013-02-24 14:48:38

kensai
Member
From: Puerto Rico
Registered: 2005-06-03
Posts: 2,484
Website

Re: Help with VirtualHost (SOLVED)

Thanks guys, this and other configurations mistakes I found did it for me. Thanks a lot, I'm trying to polish my webserver admin skills.


Follow me in: Identi.ca, Twitter, Google+

Offline

Board footer

Powered by FluxBB