LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   apache virtual host problem - webmin (https://www.linuxquestions.org/questions/linux-software-2/apache-virtual-host-problem-webmin-110780/)

reedsmith 10-31-2003 08:25 AM

apache virtual host problem - webmin
 
Hello,

I set up additional virtual hosts on my machine through webmin apache but the default domain name points to the first virtual host. Do I have to set up a default virtual host and point it to the default directory or is there an error happening.

Thanks Reed

phz 10-31-2003 10:01 AM

Hi

I'm trying to learn apache myself, but haven't tried the 'virtual host' settings. I sorta did it the easy way by creating symlinks from the doc root dir to the various users dir. Dunno if there are security issues against doing it this way, but i found it pretty easy :)

In my server doc root dir ( /www/html ) i made the symlinks like:

ln -s /home/user1/html user1

This makes a symlink called 'user1' that points to user1's html directory. The url would then be: www.whatever.com/user1

bobby sands 11-01-2003 12:24 PM

hi- i'm having exactly the same problem. i have set up a number of virtual hosts, restarted apachectl etc. etc. and nothing happens- every domain points to the default virtual host. Here are the details from the httpd.conf file:

NameServer xxx.xxx.xxx.xxx:80 (an ip address)

and each virtual host takes the form:

<VirtualHost xxx.xxx.xxx.xxx>
ServerAdmin webmaster@xxxxxx.co.uk
DocumentRoot /usr/local/apache/htdocs/xxxxxx
ServerName www.xxxxxx.co.uk
ServerAlias xxxxxx.co.uk *.xxxxxx.co.uk
ErrorLog logs/xxxxxx.co.uk-error_log
CustomLog logs/xxxxxx.co.uk-access_log common
</VirtualHost>

do i have to use the gateway IP address of the machine or something?

also- does it matter that the domain(s) pointing to the machine are pointing to an ip address rather than a name.

it is getting supa frustrating now!

cheers for listening- hope someone answers...

phz 11-07-2003 12:09 PM

As i'm pretty new to apache myself, i'm not sure this will help, but... I believe i read an example file on virtual severs somewhere, and as i remember it each virtual server was given a different port. Something like <VirtualHost 1st.server.ip.adr:8001>
</VirtualHost>
<VirtualHost 2nd.server.ip.adr:8002>
</VirtualHost>

Dunno if this helps, just a thought :)

Cerbere 11-08-2003 12:52 AM

reedsmith: Yes, you must set up a default VirtualHost. Any domain name that resolves to your IP and is not listed in a VirtualHost directive will default to the first one listed. This caused me some embarassment when I was hosting a small business and when my client left the www off of his URL, it defaulted to the first VH on my server, which happened to be a porno site! (Which is why you want to add ServerAlias *.domainname.com to each VH directive)

From the Apache docs:
Code:

For example, suppose that you are serving the domain www.domain.tld and you
wish to add the virtual host www.otherdomain.tld, which points at the same IP
address. Then you simply add the following to httpd.conf:

    NameVirtualHost *

    <VirtualHost *>
    ServerName www.domain.tld
    DocumentRoot /www/domain
    </VirtualHost>

    <VirtualHost *>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

phz: First off, unless you have a specific reason for assigning other ports, don't do it. It'll only make it harder to reach your site if everyone has to append a port number to your URL.

Secondly, if you rename the /home/user1/html directory to /home/user1/public_html, then apache will serve the pages there to the URL www.whatever.com/~user1. So you don't need the symlinks.

[edit] Or you can change the following section in httpd.conf:
Code:

<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

to:
Code:

<IfModule mod_userdir.c>
    UserDir html
</IfModule>

[/edit]

bobby sands: I think you need to use the 'NameVirtualHost *' (or 'NameVirtualHost xxx.xxx.xxx.xxx:80') directive, not NameServer xxx.xxx.xxx.xxx:80.

Enjoy!
--- Cerbere

phz 11-08-2003 08:02 AM

Thanx for the info - it really made a few things a bit clearer to me :) All those docs & howto's really can be an information overdose to us not so experienced with linux/apache...


All times are GMT -5. The time now is 09:07 PM.