Link to home
Start Free TrialLog in
Avatar of mwhuen
mwhuen

asked on

Virtual Hosting

what is virtual hosting?

I want to administrate 2 web sites in only one apache server, how to do it?
Avatar of hansendc
hansendc

It takes a little bit more than can be explained here.  Have you even LOOKED at the Apache documentation?  It isn't an exceedingly difficult thing to do.  

Look at these docs:
http://www.apache.org/docs/vhosts/index.html
It is quite simple. First you must assure that both web addresses point to your Apache's IP address. Then there are a few options to tweak in /usr/local/apache/conf/httpd.conf

 As our friend above said, it's not difficult to do it.
Eat: your suggested path is not correct for Debian, Redhat, SuSE, TurboLinux, Bestlinux. (Adn dont give me the "It is not my fault if they use a 'broken' distribution and they should all change to slackware") ;)
Where do all the other distros put it?
RH / mandrake / SuSE uses

/etc/httpd/conf/httpd.conf and srm.conf for vhosting (and of cource access.conf)

not to sure about the others, but it is under the /etc structure.
j2 , Eat is 100% correct about the path; provided that he mentioned that he installed his own apache server, and not selected to install apache during installation of the OS. This way is also in my view the best route to follow, for one reason alone, installing frontpage server extensions on your web is near impossible if you use apache from the OS install.
mwhuen, as others have mentioned, it is not "as" easy as some might suggest, there are a couple of things you need to do first. You need a static IP for your server box. (not just any IP you can think of, this IP must be unique on the internet) If you have such an IP, then you need a name server as well. The name server must then point any requests for webpages you want to host on your pc, to your pc's IP. For instance, if you want to host two pages www.1.com, and www.2.com, both need to point to the same IP. On your webserver box, you will then need to edit the httpd.conf file. If you install your own apache, it will be at /usr/local/apache/conf/httpd.conf, if it was installed with the OS, it will be in /etc/httpd/conf/httpd.conf
Don't edit the other *.conf files, you only need to edit the httpd.conf file.
You will add the virtual hosts right at the bottom of that file ( there will already be a sample of a virtual host, you just need to change it to match your needs). You will also need to ensure that the rest of the file is correct, eg. server name, and you should also add NameVirtualHost xxx.xxx.xxx.xxx :80
where xxx = your IP.
Then you will also need to ensure that the permisiions of your web files are set so that it can be accessed from outside, therefore, make it writeable to the owner of the web only, and all the other permissions can be set active.
hansendc: I really don't know how many Linux distributions are there today, as I've found my favourite distribution already. Slackware puts it in /usr/local/apache, the place suggested by nobody else than the Apache developing team. Should we argue with them? :)

j2: As I'm developing e-commerce applications based on MySQL + PHP3 + Apache, I had to build Apache myself with support for these tools. As a good admin, I've installed Apache in the recommended path, that is /usr/local/apache. That is no surprise to me, as a good distribution like Slackware already puts it there. Also, srm.conf is deprecated (if you've ever built your own Apache, you'll see the message left by the Apache developing team in this same file) so you should find all configuration parameters inside /usr/local/apache/conf/httpd.conf.

psimation: I've forgot about those details! I mean, the real IP thing and DNS. I thought that was already well-known. Thanks!
Avatar of mwhuen

ASKER

Thanks for all you guys,
I learnt much in this question.
psimation said I need a name server as well,
can you guys give more information about it?

does linux include name server? how to configure it?
Yes, named is the DNS server (name server) that comes with the BIND package. It's configured in /etc/named.conf. Configuring it is quite simple and you should have no trouble doing it as long as you have some free time to carefully read the DNS-HOWTO file included in your /usr/doc/Linux-HOWTOs directory. It won't take more than a few hours if you do it slowly and patiently.

 The DNS server is responsible for telling everybody who's holding the web addresses you plan on hosting. Just like: "Hey!! I'm the owner of www.mwhuen.com!!"

 Hope this get you where you want.

 Good luck!
ASKER CERTIFIED SOLUTION
Avatar of Sokka
Sokka

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial