Creating Apache SubDomains
Creating Subdomains with the Apache Server
Subdomains
To do this, we need to go back to our copy of httpd.conf.
First: Find the line:
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
Add this below Ok, you will have to change these directorys to what you want. You MUST have a .tk do do this. (or some extension). For the DocumentRoot, the directory would turn out to be c:\apache2\sub\ but you don't add the C:\ and also, be sure you add the correct /'s. For the Errorlog and the transferlog, besure to create thoes files before running your server.
<VirtualHost sub.whatever.tk>
ServerAdmin Any@email.here
DocumentRoot /apache2/sub/
ServerName sub.iponu.tk
ErrorLog /apache2/sub/logs/error.log
TransferLog /apache2/sub/logs/transfer.log
</VirtualHost>
That is how you can create subdomains with apache. Any questions, Please PM me.
Re: Creating Apache SubDomains
Quote:
Originally posted here by JCHostingAdmin
Creating Subdomains with the Apache Server
<b>Subdomains</b>
To do this, we need to go back to our copy of httpd.conf.
First: Find the line:
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
Add this below Ok, you will have to change these directorys to what you want. You MUST have a .tk do do this. (or some extension). For the DocumentRoot, the directory would turn out to be c:\apache2\sub\ but you don't add the C:\ and also, be sure you add the correct /'s. For the Errorlog and the transferlog, besure to create thoes files before running your server.
<VirtualHost sub.whatever.tk>
ServerAdmin Any@email.here
DocumentRoot /apache2/sub/
ServerName sub.iponu.tk
ErrorLog /apache2/sub/logs/error.log
TransferLog /apache2/sub/logs/transfer.log
</VirtualHost>
That is how you can create subdomains with apache. Any questions, Please PM me.
You also probably wish to modify the manner in which your directories are handled, and potentiall want to add a cgi-bin:
<VirtualHost *>
ServerAdmin an@email.here
DocumentRoot /apache2/sub/
ServerName sub.iponu.tk
ErrorLog /apache2/sub/logs/error.log
TransferLog /apache2/sub/logs/transfer.log
ScriptAlias /cgi-bin/ "/apache2/sub-cgi/"
<Directory /apache2/sub>
AllowOverride AuthConfig
Options Includes FollowSymLinks
</Directory>
<Directory /apache2/sub-cgi>
AllowOverride AuthConfig
Options Includes FollowSymLinks ExecCGI
</Directory>
</VirtualHost>
You don't actually need a .tk address, you could setup your own domain if you're running your own name server, of say .home. You could then create server aliases for Jim.home, Bob.home, etc., etc., and have your own internal web setup.
Keep in mind that name based virtualhosting is a highly efficient way of handling your subdomains. Also look into the ServerAlias keyword.
Quote:
Originally posted here by Dome
Its been a while since ive messed with that, but im pretty sure you also need to put in that subdomain in your DNS settings for it to work properly...
Just thought id add alittle something
Actually, no, this is not needed.
Quote:
Originally posted here by fizzie
I also believe that unless you assign the virtual domain it's own ip address you will need to use the NamedVirtual directive as well, however, it has been a while since I have done this as well.
I believe the NameVirtualHost directives were deprecated as of 1.3.12, but I'm not sure on that. I use the setup JC describes above at work to host several domains, and they all work fine off of one IP address.