LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-14-2008, 01:22 PM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
Apache 2 and virtual hosts


I am desperatly trying to get apache to show two different webpages depending on whether the user typed in www.domain.com or foo.domain.com in the browser.

I have tried a bunch of different setups but either I get some error about overlapping virtual hosts or I get the same webpage no matter what url I type into the browser.

So, can someone just please tell me how I need to setup apache to do this for me?

www.domain.com should show the page inside /var/www/default/
foo.domain.com should show the page inside /var/www/foo/

Simple. But Apache makes it complex. I am going crazy.
 
Old 06-14-2008, 01:30 PM   #2
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Rep: Reputation: 62
Yeah, I've done this - its not too bad once you know what you're doing. Too tired to answer properly now, but message me or something if you don't get it sorted in the next couple.
 
Old 06-16-2008, 05:37 AM   #3
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
If I had to guess, you are getting the "overlapping virtual hosts" error because you are putting a name in the virtualhost tag line. To do what you are trying to do (assuming you have DNS pointing both your URLS to the same server), you would have the following in your httpd.conf file:

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot /var/www.domain.com/
ServerName www.domain.com
ErrorLog logs/www.domain.com-error_log
CustomLog logs/www.domain.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@foo.domain.com
DocumentRoot /var/foo.domain.com/
ServerName foo.domain.com
ErrorLog logs/foo.domain.com-error_log
CustomLog logs/foo.domain.com-access_log common
</VirtualHost>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
Apache with virtual hosts linuxmandrake Linux - Security 1 09-14-2006 12:53 PM
Apache Virtual Hosts dienerk Linux - General 15 10-16-2004 12:46 AM
apache virtual hosts smaida Linux - Software 3 06-20-2004 04:28 PM
Apache/Virtual Hosts Help C-Squared Linux - General 9 08-04-2003 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration