Click to See Complete Forum and Search --> : Apache - SubDomains - IP's


ozpacific
02-26-2003, 09:20 PM
Hi All,

I am just setting up a automated freehosting system part of my business and i want to know how to set up apache for sub-domains under 1 ip address, i know it is possible?? just dont know how to do it. I have done all the script side of things.

I am running Apache 2.0.44 , PHP 4.3.0 , Windows XP Pro

Regards,
Matt

mogster
02-27-2003, 07:30 PM
Yo!

Yes it is possible, and not very difficult to set up virtualhosts. But I don't know if this goes for apache 2.x, as I've heard this is a bit of a nutter - especially in combination with php.
Have you considered using the 1.3.x version?

Anyway here's an example from that conf - don't know if it differs in the new version:
## This is specified only once above all your virtualhosts ##
NameVirtualHost 192.168.10.80

### mydomain 17. oktober 2002 / myname ###
<VirtualHost 192.168.10.80>
ServerName www.yourdomain.com
ServerAlias yourdomain.com
ServerAdmin admin@yourdomain.com
DocumentRoot /the/pathto/document_root
ErrorLog logs/yourdomain.error
TransferLog logs/yourdomain.access
</VirtualHost>

Now, between the virtualhost tags you can do all sort of things to protect dirs under web root, and other things specific to that domain.
This will protect all files with ending .inc in dir document_root/includes from being viewed. The error doc is not included, though - it returns a server error. But one don't get to view the inc's:
<Location /includes/*.inc>
Order deny,allow
Deny from all
ErrorDocument 404
</Location>

You could also provide basic protection (.htaccess) inside the vh-tags if you want to protect it:
<Location>
AuthName "The headline to appear in the prompt"
AuthType Basic
AuthUserFile /apache_path/apache/auth/the_password_file.txt
require user gunga-din monsoon john
AuthAuthoritative on
</Location>

After editing, you'll need to restart apache for the changes to take effect.

knutm

bearau
07-27-2003, 12:47 PM
what about actual subdomains ie
main domain
www.freddy.com

subdomain
pets.freddy.com

how do you set this up?