views:

1284

answers:

1

How do I configure Apache2 via webmin or command-line (I'm using RHEL5 Linux) so that I can have multiple domains on the same server on the same port but in different subdirectories?

For instance, trying to get homerentals.ws and homerepair.ws to be detected on port 80 (default port) on the same server. I know that my DNS holds the two addresses and web hits currently go to the same test page. Now all I need is for web hits to go to a subdirectory, but not show this subdirectory. For instance, I do not want people going to http://homerentals.ws and being redirected back to http://homerentals.ws/homerentals/. Instead, http://homerentals.ws would go to /var/www/html/homerentals, while http://homerepair.ws would go to var/www/html/homerepair, but would not look any differently in the URL.

On IIS, I did this once with host-header detection. But I don't know how to do it on RHEL5 Linux via webmin or file editing. I'm stuck.

+1  A: 

The feature you're describing is known as virtual hosts. Have a look at Apache's documentation. In general you need to edit /etc/apache2/httpd.conf file to make things happen (maybe it can be edited through webmin, but I'm not familiar with it).

Joonas Pulakka
Thanks, I'm still stuck, and that's why I posted this. I went to:http://httpd.apache.org/docs/2.2/vhosts/examples.htmlThe first example is me in a nutshell. However, RHEL sticks a default httpd.conf ahead of the virtual hosts and I think it's preventing my virtual host from even engaging.
Sorry, I'm not exactly familiar with RHEL and its default httpd.conf. Perhaps you could just replace the default httpd.conf with your own version (backup the default, just in case ;-)
Joonas Pulakka
Oh, one thing (this may be trivial) - you must restart Apache after editing the configuration file, otherwise nothing will happen.
Joonas Pulakka
At this very second, a guy named Neal at Rackspace is working the ticket. I'll go back and see what he does to the httpd.conf file and share with everyone because I would think this is a very common task but few people seem to know how to explain when someone has an existing, long httpd.conf file.
Thanks. One difficulty with explaining this task is that what needs to do to the existing httpd.conf depends on what already is there.
Joonas Pulakka
The fix turned out that my work in Webmin to create a new virtual host, which I tweaked by editing the httpd.conf file to add a ServerAlias (a typical thing to also do so you can accept "www."), would work only if I fixed the file permission on the directory. Rackspace fixed that and it worked.

related questions