LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Host 2 websites on Fedora (https://www.linuxquestions.org/questions/linux-newbie-8/host-2-websites-on-fedora-656485/)

niner710 07-17-2008 05:43 PM

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!

manwichmakesameal 07-17-2008 05:51 PM

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.

custangro 07-17-2008 06:03 PM

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

FranDango 07-18-2008 06:45 AM

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

niner710 07-21-2008 04:21 PM

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

FranDango 07-21-2008 05:04 PM

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.

niner710 07-21-2008 05:30 PM

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?

custangro 07-21-2008 06:16 PM

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

niner710 07-21-2008 11:27 PM

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?

niner710 07-21-2008 11:40 PM

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


All times are GMT -5. The time now is 12:24 PM.