# Solved: Creating SubDomain - Apache HTTP



## computer_pet (Jun 22, 2003)

Hi,
Can someone tell me how to make a subdomain in apache. I need to make subdomain.mydomain.com go to 'C:/www/subdomain'. I think I have to use Virtual Host, except when I do this it also affects the main domain (mydomain.com documents root goes to c:/www/subdomain, instead of c:/www.) I think I have to make an A record on my DNS server, except what do I have to add to my conf file?

I only have one IP (i think that matters)

Thanks


----------



## computer_pet (Jun 22, 2003)

Any help?????


----------



## computer_pet (Jun 22, 2003)

Top


----------



## computer_pet (Jun 22, 2003)

This is what I have been using in my conf file:
<VirtualHost *:80> 
ServerAdmin [email protected] 
DocumentRoot "d:/Program Files/Apache Group/Apache2/htdocs/tvthemes"
ServerName messageboard.something.com
<Directory "d:/Program Files/Apache Group/Apache2/htdocs/tvthemes"> 
Options Indexes FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 
</VirtualHost>

[I replaced my actual email address, and domain here for privacy ]

I also made an A record that points my IP address (which is the same IP). When this is in place in my conf file mydomain.com does to 'd:/Program Files/Apache Group/Apache2/htdocs/tvthemes' also the subdomain goes to this address. How do I make only that specific subdomain go to that folder, and not affect the main address?


----------



## computer_pet (Jun 22, 2003)

??? anyone ???


----------



## Squashman (Apr 4, 2003)

Upload your whole config file as an attachment.


----------



## computer_pet (Jun 22, 2003)

LwdSquashman said:


> Upload your whole config file as an attachment.


I have attached my apache config file (as txt), all virtual hosts I have tried but failed are at the bottom of the file. I have not deleted anything from them except have commented them (so I can still use my server). Please read the top of the file as I have left a message .

Thanks again

I will be here the whole day, until about 10pm  (around 12 hours from now)


----------



## tdi_veedub (Jan 29, 2004)

This is the virtual hosts section of my httpd.conf file. You will see I have two sections to my Virtual hosts section. The ones at the bottom are subdomains of pcfixme.com, and the ones above are subdomains of gotdns.com.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/homeharmonyonline/public_html
ServerName homeharmonyonline.gotdns.com
ErrorLog /home/homeharmonyonline/error_log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/pcfixme/public_html
ServerName pcfixme.com
ErrorLog /home/pcfixme/error_log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/mindscapes/public_html
ServerName mindscapes.gotdns.com
ErrorLog /home/mindscapes/error_log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/powertechsys/public_html
ServerName powertechsys.gotdns.com
ErrorLog /home/powertechsys/error_log
</VirtualHost>
#
# 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 *:80>
# ServerAdmin [email protected]
# 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>

# By default, all external Apache modules are disabled. To enable a particular
# module for Apache, make sure the necessary packages are installed. Then
# uncomment the appropriate Include line below, save the file, and restart
# Apache. Note that some modules may need additional configuration steps. For
# example, mod_ssl requires a site certificate which you may need to generate.
#
# Lastly, if you remove a module package, be sure to edit this file and comment
# out the appropriate Include line.

# ==> mod_php configuration settings <==
#
# PACKAGES REQUIRED: openssl-solibs (A series) and/or openssl (N series),
# mysql (AP series), gmp (L series), and apache (N series)
#
#Include /etc/apache/mod_php.conf

# ==> mod_ssl configuration settings <==
#
# PACKAGES REQUIRED: apache (N series) and openssl (N series)
#
#Include /etc/apache/mod_ssl.conf

<VirtualHost *>
DocumentRoot "/home/pcfixme/public_html"
ServerName www.pcfixme.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/home/powertechsys/public_html"
ServerName powertechsys.pcfixme.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/home/mindscapes/public_html"
ServerName mindscapes.pcfixme.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /home/darrin/public_html
ServerName pcfixme.gotdns.com
</VirtualHost>


----------



## computer_pet (Jun 22, 2003)

I tried tdi_veedub's code and it worked 

Maybe I had copied something wrong ??

This is what I added to the bottom of my conf file:



> NameVirtualHost *:80
> <VirtualHost *:80>
> ServerAdmin #############
> DocumentRoot "d:/Program Files/Apache Group/Apache2/htdocs/tvtheme/"
> ...


----------



## ~Candy~ (Jan 27, 2001)

FYI, you can now mark your own threads solved by using the THREAD TOOLS drop down box. Pass the word.


----------



## computer_pet (Jun 22, 2003)

Thanks,
Did not know about that
Computer_pet


----------

