LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-01-2005, 09:58 AM   #1
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Rep: Reputation: 15
Is there an easy way to add a virtual host?


Hi.
Can someone step me through the process of adding a virtual host to my server? I only have the one ip pointing to my server. I heard I could use the same ip and have different virtual host.

I've been running my server with one domain name for years.
I'll call it domainname.com

I registered a name at networksolutions. I wanted to start a store to help support the site. Let's call it store.com

I searched using google and this site trying to solve my problem. The examples I have found so far don't seem to work.

I'll try what you say then report back here to see what happens.

Apache/1.3.33 (Unix) PHP/4.3.10 mod_ssl/2.8.22 OpenSSL/0.9.7e


Thanks.
Dave.


P.S. I can reboot apache with any changes that need to be done to httpd.conf file
 
Old 01-01-2005, 11:31 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
Have you read the Apache documentation on virtual hosting? Pay particular attention to name based virtual hosting. You can easily use this to run site1.store.com, site2.store.com, site1.otherstore.com, etc. from the same IP address.
 
Old 01-01-2005, 02:05 PM   #3
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
Would it matter if they had completely different domain names?

I tried adding the virtual host directive for the new domain name and I couldn't access the original domain name.
So I removed it and came here.
Should I post my httpd.conf file here and maybe remove a few sensitive things?
 
Old 01-01-2005, 02:55 PM   #4
andkore
LQ Newbie
 
Registered: Dec 2004
Posts: 5

Rep: Reputation: 0
As he said, check the Apache docs, I _believe_ that they have pretty good info about virtual hosts. Actually after looking, their documentation seems the best (of course =P ) http://httpd.apache.org/docs/vhosts/...sed.html#using
is what you want. Yes you can do multiple domains, not just subdomains.
Andkore
 
Old 01-01-2005, 03:45 PM   #5
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
Okay.
I tried it then rebooted the server.

<VirtualHost *>
ServerName www.originaldomain.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.newdomain.com
DocumentRoot /usr/local/apache/htdocs/store
</VirtualHost>

After adding this I typed in the first domain name and it worked fine. Which is the original domain name for the server.

Here is the kicker.
When I type in the second domain name it takes me to the same location as the first domain name.
/usr/local/apache/htdocs

Could my problem have anything to do with the virtualhost directive in the SSL section below?

## SSL Virtual Host Context
##

<VirtualHost _default_:443>

# General setup for the virtual host
DocumentRoot "/usr/local/apache/htdocs"
ServerName www.originaldomain.com
ServerAdmin dave@originaldomain.com
ErrorLog /usr/local/apache/logs/ssl_error_log
TransferLog /usr/local/apache/logs/ssl_access_log

# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
 
Old 01-01-2005, 03:59 PM   #6
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
Before the virtual host directives you need
Code:
NameVirtualHost *:80
 
Old 01-01-2005, 05:15 PM   #7
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
I'm sorry.
I forgot to post that.
This was added before the virtualhost directive.
NameVirtualHost *:80

It is strange. It seems like everywhere I read it is supposed to be easy to do.

Everywhere I go it says
to add this line
NameVirtualHost *:80
<VirtualHost *>
ServerName www.originaldomain.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.newdomain.com
DocumentRoot /usr/local/apache/htdocs/store
</VirtualHost>

When I use either domain name they both go to this directory.
/usr/local/apache/htdocs

I wonder why I can't get www.newdomain.com to go to
/usr/local/apache/htdocs/store
 
Old 01-01-2005, 05:32 PM   #8
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
OK, I'm a little confused about something.....A couple of posts ago you said

Quote:
Could my problem have anything to do with the virtualhost directive in the SSL section below?
Are you trying to do virtual named hosts over an SSL connection? If so, I don't think that is going to work. I don't remeber the exact details of why, but the upshot is that for an SSL connection you can only have one domain per IP address. The name based virtual hosting really only works with non-secure connections.
 
Old 01-01-2005, 05:48 PM   #9
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
Right. The original domainserver has ssl

So does that mean I will have to have individual ip addresses and not be able to use the virtual directive using domain names?

I didn't need ssl with the second domain name.


I appreciate you guys help.
 
Old 01-01-2005, 06:02 PM   #10
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
You're going to want a second opinion because I am no expert on this, but here is my understanding.......You can do name-based virtual serving with a single IP, but anyone using an SSL connection will always be connected to the first virtual server listed (in your case, originaldomain.com) regardless of the domain they are trying to connect to. Using a normal connection should allow users to connect to newdomain.com or orignaldomain.com. As long as newdomain.com doesn't need a secure connection, you should be fine. However, if/when they do, you'll need to add an IP and move to IP-based virtual hosting.
 
Old 01-01-2005, 07:32 PM   #11
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
I had read somewhere if you use ssl you have to have more than one ip.

I thought it applied only if you have two host trying to use ssl. I really don't know.

Anyone run across this before?
 
Old 01-02-2005, 09:13 PM   #12
dave4545
Member
 
Registered: Oct 2002
Distribution: Redhat Linux 7.0 Apache/1.3.27 PHP Version 4.3.1 server api Apache
Posts: 46

Original Poster
Rep: Reputation: 15
The guy that helps with the server is going to give us another ip, I believe.

We'll see.
 
  


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
Easy way to host multiple sites on one IP BrettPower Linux - Networking 0 03-06-2004 11:49 PM
virtual host ziggie216 Linux - General 2 12-22-2003 07:38 PM
Virtual Host |Drakehash| Linux - Networking 0 07-17-2003 04:02 PM
changing my host name...not as easy as one might think Atreides Linux - General 1 06-05-2003 12:08 PM
VIrtual host thep Linux - General 10 08-06-2002 12:28 PM


All times are GMT -5. The time now is 07:41 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration