Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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
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.
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?
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...
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.