LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-17-2008, 05:43 PM   #1
niner710
Member
 
Registered: Apr 2008
Posts: 37

Rep: Reputation: 15
Host 2 websites on Fedora


Hi,

I am currently using an old E machine to host a website from my DSL line at home. I am using Fedora 8, and was wondering if its possible to host another website on the same machine from my home? Can you host 2 different websites from the same Apache server? I have a dynamic IP address at home so I use the ddclient.conf with dyndns to change my IP on my server whenever my ISP decides to change IP's on me. I open up my firewall to allow httpd access and it gets forwarded to my Linux server. Can anyone point me in the right direction? Thanks!
 
Old 07-17-2008, 05:51 PM   #2
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 804

Rep: Reputation: 110Reputation: 110
Look up how to use virual hosts with apache. I don't have mine set up that way, but I'm pretty sure that's what you're looking for.
 
Old 07-17-2008, 06:03 PM   #3
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
I Spent 2 seconds on google search...

http://httpd.apache.org/docs/1.3/vhosts/ip-based.html

Good resource for all your Linux questions

http://google.com/linux

Last edited by custangro; 07-17-2008 at 06:13 PM.
 
Old 07-18-2008, 06:45 AM   #4
FranDango
Member
 
Registered: Jun 2008
Posts: 101

Rep: Reputation: 15
You can set up virtual hosts (any number you want) within httpd.conf or use Fedora's GUI admin tool for HTTPD. Virtual hosts can be IP or name-based. In your case name-based is the reasonable choice, because you have a single incoming IP with your DSL account (I suppose so).

Apache.org has proper documentation on virtual hosts. At the basic level it's quite trivial to do, a matter of a few minutes.

You need to register your domain names with your DSL's IP number assigned to the registration. For test purposes simply add your test domain names into /etc/hosts with localhost or 127.0.0.1 as the target IP.

Linux Archive

Last edited by FranDango; 09-20-2008 at 05:10 AM.
 
Old 07-21-2008, 04:21 PM   #5
niner710
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Ok, you were right. It was pretty easy and I just changed the httpd.conf file. Now I have 2 domain names that are using name based virtual hosting off 1 IP. What do I do with the /etc/hosts file. I have one website on localhost(127.0.0.1), but what do I do with the other one(lets say localhost2). I can't set localhost2 to 127.0.0.1. How do I do it so I can view both of the websites? Thanks

Last edited by niner710; 07-21-2008 at 04:29 PM.
 
Old 07-21-2008, 05:04 PM   #6
FranDango
Member
 
Registered: Jun 2008
Posts: 101

Rep: Reputation: 15
All your virtual hosts can point to localhost (which is 127.0.0.1 actually). The beauty of name-based virtual hosting is that all incoming requests for the same IP (in this case localhost) is filtered by Apache based on the domain names. Apache will then lead to the webroot directory for the given domain name.

You should have different webroots for each virtual hosts, though it is possible to make one webroot location overlap or being a subdirectory of an existing other webroot.

Note: if you access your webserver by IP-number instead of a domain name, then the first virtual host from httpd.conf will be shown.
 
Old 07-21-2008, 05:30 PM   #7
niner710
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
So what happens if I have a mySQL database server that I want to connect to. Could I connect 2 websites and a mySQL database server to the same IP? Is there a name based virtual hosting way to add a database too?
 
Old 07-21-2008, 06:16 PM   #8
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
An IP address will answer to whatever port it's listening on. Mysql listens on port 3306 and apache listens on port 80...so you could run mysql on the same IP address that your website is running...(I wouldn't recommend thison a production enviroment...but for personal use it's ok)

Do a netstat -a to find out what ports are listening...

-C

Last edited by custangro; 07-21-2008 at 06:17 PM.
 
Old 07-21-2008, 11:27 PM   #9
niner710
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Ok, thanks. That clarifies my question on SQL. This maybe a stupid question but lets say I enter in localhost.localdomain and get the greeting page of one of my websites(website A). I'm just curious how would I look at my other website(website B) from my server(other then going to the url address from my browser). Website B is mapped to localhost.localdomain I'm guessing? Could I map website B to localhost2.localdomain? How would I do that?
 
Old 07-21-2008, 11:40 PM   #10
niner710
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Ok, nevermind figured it out. Here is what I did for other people's reference.

Changed my httpd.conf file like this.
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/www/"
ServerName localhost
</VirtualHost>
<VirtualHost testsite1>
DocumentRoot "C:/www/Drupal-4.6.3"
ServerName testsite1
</VirtualHost>

Then changed my /etc/hosts file to look like this.
127.0.0.1 localhost
127.0.0.1 testsite1
 
  


Reply



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
Apache - running multiple websites on one host xtra Linux - General 5 06-30-2010 04:51 AM
certain websites hang from fedora, but not windows or mac yevaud Linux - Networking 4 11-11-2006 12:08 AM
How to host two websites on one computer klintonray Linux - Software 8 07-23-2003 02:19 PM
I want to host Websites king_trance Linux - Networking 2 07-04-2002 01:06 AM
Apache SSL - how to virtual host two or more secure websites on the same machine? bjoshi Linux - Networking 0 08-30-2001 07:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 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