openSUSE Forums > Network/Internet » Virtual Hosts

Go Back   openSUSE Forums > Network/Internet
Forums FAQ Members List Search Today's Posts Mark Forums Read


Network/Internet Questions about internet applications, network configuration, usage (SAMBA, network printing, NFS)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 21-Oct-2009, 00:38
Puzzled Penguin
 
Join Date: Jul 2008
Posts: 19
Bman22 hasn't been rated much yet
Default Virtual Hosts

I am trying to set up a subdomain on my webserver, and from what I can tell, that is called a virtual host on Apache. I tried putting
Code:
NameVirtualHost *:80

<VirtualHost *:80>
 DocumentRoot /srv/www/htdocs
 ServerName www.(site).info
 ServerAdmin root@(site).info
 <Directory /srv/www/htdocs>
  AllowOverride None
  Order allow,deny
  Allow from all
 </Directory>
</VirtualHost>

<VirtualHost *:80>
 DocumentRoot /srv/www/mail
 ServerName mail.(site).info
 ServerAdmin root@(site).info
 <Directory /srv/www/mail>
  AllowOverride None
  Order allow,deny
  Allow from all
 </Directory>
</VirtualHost>
and no matter what subdomain i go to, it just takes me to the root domain. I set the hostname settings to redirect mail.(site).info, and www.(site).info to 127.0.0.1, and everything else is set the same as the examples on the Apache2 website. Any idea why it isn't working?
Reply With Quote
  #2 (permalink)  
Old 21-Oct-2009, 07:20
microchip8's Avatar
Shaman Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 2,194
microchip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the rough
Default Re: Virtual Hosts

Use name-based hosts, or for each host create a separate virtual host file?
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #3 (permalink)  
Old 21-Oct-2009, 08:09
Puzzled Penguin
 
Join Date: Jul 2008
Posts: 19
Bman22 hasn't been rated much yet
Default Re: Virtual Hosts

how would i set up a name based host. According to one of the sites i looked at, that is a name based host. Should I just replace the *:80 with site:80?
Reply With Quote
  #4 (permalink)  
Old 21-Oct-2009, 08:15
microchip8's Avatar
Shaman Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 2,194
microchip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the rough
Default Re: Virtual Hosts

You're right, I overlooked that (the joy of replying too fast while in a hurry)

I do not see much wrong with your config, but you way want to bind them to a specific address and also since these hosts run on one and the same machine, just under different names, you may want (or need) ServerAlias

Docs over here: Name-based Virtual Host Support - Apache HTTP Server
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #5 (permalink)  
Old 21-Oct-2009, 12:42
Student Penguin
 
Join Date: Jun 2008
Location: Oregon, US
Posts: 86
elserj hasn't been rated much yet
Default Re: Virtual Hosts

Could it just be as simple as restarting the httpd service after changing the Virtual Hosts? Any changes to the httpd.conf file require restarting the service.

Code:
sudo /etc/init.d/httpd restart
Reply With Quote
  #6 (permalink)  
Old 21-Oct-2009, 12:49
Camaleón
Guest
 
Posts: n/a
Default Re: Virtual Hosts

Bman22 wrote:

> I am trying to set up a subdomain on my webserver, and from what I can
> tell, that is called a virtual host on Apache. I tried putting


(...)

> and no matter what subdomain i go to, it just takes me to the root
> domain. I set the hostname settings to redirect mail.(site).info, and
> www.(site).info to 127.0.0.1, and everything else is set the same as the
> examples on the Apache2 website. Any idea why it isn't working?


Maybe this helps :-)

Apache Web Server & Virtual Host on openSUSE : Part 2
http://vavai.net/2009/03/02/apache-w...ensuse-part-2/

Greetings,

--
Camaleón
Reply With Quote
  #7 (permalink)  
Old 21-Oct-2009, 13:12
Puzzled Penguin
 
Join Date: Jul 2008
Posts: 19
Bman22 hasn't been rated much yet
Default Re: Virtual Hosts

Ok, that tutorial looks great, I will try it when I get home. I had tried restarting the Apache server, but it seems that I do need the extra stuff in that tutorial. Another question on this topic, is there a way to set the public html directory to be at (username).(site).com instead of (site).com/~(username)?
Reply With Quote
  #8 (permalink)  
Old 21-Oct-2009, 15:22
microchip8's Avatar
Shaman Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 2,194
microchip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the rough
Default Re: Virtual Hosts

Quote:
Originally Posted by Bman22 View Post
Ok, that tutorial looks great, I will try it when I get home. I had tried restarting the Apache server, but it seems that I do need the extra stuff in that tutorial. Another question on this topic, is there a way to set the public html directory to be at (username).(site).com instead of (site).com/~(username)?
Yes, but that could be difficult since this is a compile option but I don't know how SUSE compiles Apache. If they "hardcoded" it to be in ~username, you'll have to recompile apache again and modify/change that with an option during configure time
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #9 (permalink)  
Old 21-Oct-2009, 15:41
Puzzled Penguin
 
Join Date: Jul 2008
Posts: 19
Bman22 hasn't been rated much yet
Default Re: Virtual Hosts

from what i can tell, it is just the use of the "public_html" folder that is a compile option, but i think i will just set up virtual hosts for the users i have, unless somebody has a way to do it automatically
Reply With Quote
  #10 (permalink)  
Old 21-Oct-2009, 15:56
Puzzled Penguin
 
Join Date: Jul 2008
Posts: 19
Bman22 hasn't been rated much yet
Default Re: Virtual Hosts

I got virtual hosts working, but with one small problem. In order to get the server to go to the main domain name, i have to create another virtual host that loads the main site. Is there anyway to make it so that leaving no subdomain just takes it to the main site without creating a virtual host for it?
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2