Jump to content


hat work


  • Please log in to reply
4 replies to this topic

#1 OFFLINE   crp

crp

    Board Bigwig

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 2,571 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 ?
Of all tyrannies, a tyranny sincerely exercised for the good of its victims may be the most oppressive. It would be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end for they do so with the approval of their own conscience. ~C. S. Lewis

#2 OFFLINE   Peachy

Peachy

    Anarquista De Sartorial

  • Forum Moderators
  • 5,378 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 Posted Image
del.icio.us bookmarks Posted Image


#3 OFFLINE   crp

crp

    Board Bigwig

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 2,571 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.

Of all tyrannies, a tyranny sincerely exercised for the good of its victims may be the most oppressive. It would be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end for they do so with the approval of their own conscience. ~C. S. Lewis

#4 OFFLINE   Peachy

Peachy

    Anarquista De Sartorial

  • Forum Moderators
  • 5,378 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 Posted Image
del.icio.us bookmarks Posted Image


#5 OFFLINE   Temmu

Temmu

    The Assimilator

  • Forum MVP
  • 11,773 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