Jump to content


hat work


  • Please log in to reply
4 replies to this topic

#1 OFFLINE   crp

crp

    Forum Fiend

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,695 posts

Posted 13 February 2012 - 03:17 PM

I want my CentOS server to serve up different pages depending on whether the user entered in
rh5.ex123.xyz or forum.ex123.xyz

rh5 to provide the files in /var/www/html
forum to provide the files in /var/www/mybb
I put the following into the httpd.conf
CODE
<VirtualHost *:80>
DocumentRoot /var/www/mybb
<Directory "/var/www/mybb">
allow from all
Options +Indexes
</Directory>
ServerName forum.ex123.xyz
</VirtualHost>

Problem is , entering forum.ex123.xyz or rh5.ex123.xyz both serve up the pages of forum.
How do I setup the configuration file so that the forum files only get served up if forum.ex123.xyz in the address in the URL ?

#2 OFFLINE   Peachy

Peachy

    Anarquista De Sartorial

  • Forum Admins
  • 5,356 posts

Posted 14 February 2012 - 10:09 AM

You'll need to create two virtual host stanzas.
CODE
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName rh5.ex123.xyz
  <Directory /var/www/html>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/mybb
ServerName forum.ex123.xyz
  <Directory /var/www/mybb>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>


Make sure the NameVirtualHost directive is uncommented if not already. The other thing to remember is that you will need to make sure you have DNS or host file entries on the client for both site name.
'freedom...is actually the reason that men live together in political organisations at all. Without it, political life as such would be meaningless. The raison d'Ętre of politics is freedom, and its field of experience is action'.
My Flickr Photo Blog
del.icio.us bookmarks

#3 OFFLINE   crp

crp

    Forum Fiend

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,695 posts

Posted 14 February 2012 - 02:51 PM

oh, hmm.gif
I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used.

Edited by crp, 14 February 2012 - 02:51 PM.


#4 OFFLINE   Peachy

Peachy

    Anarquista De Sartorial

  • Forum Admins
  • 5,356 posts

Posted 15 February 2012 - 10:25 AM

QUOTE (crp @ Feb 14 2012, 01:51 PM) <{POST_SNAPBACK}>
oh, hmm.gif
I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used.


I thought that too, but I think the behaviour has changed and you must explicitly put the default in a virtualhost directive. It's been a couple of years since I've set that up so if you give me some time I can verify that in my test lab.
'freedom...is actually the reason that men live together in political organisations at all. Without it, political life as such would be meaningless. The raison d'Ętre of politics is freedom, and its field of experience is action'.
My Flickr Photo Blog
del.icio.us bookmarks

#5 OFFLINE   Temmu

Temmu

    The Assimilator

  • Forum MVP
  • 9,805 posts

Posted 15 February 2012 - 03:26 PM

fascinating.  good tip, peachy!
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users