Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Creating Apache SubDomains

  1. #1

    Post 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.

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    324
    Good Job JC!
    \"I may not agree with what you say, but I will defend to the death your right to say it.\"
    Sir Winston Churchill.

  3. #3
    Banned
    Join Date
    Sep 2001
    Posts
    521
    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

  4. #4
    Junior Member
    Join Date
    Jul 2002
    Posts
    14
    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.

  5. #5
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255

    Re: Creating Apache SubDomains

    Originally posted here by JCHostingAdmin
    Creating Subdomains with the Apache Server

    &lt;b&gt;Subdomains&lt;/b&gt;
    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.
    #
    #&lt;VirtualHost *&gt;
    # 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
    #&lt;/VirtualHost&gt;

    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.

    &lt;VirtualHost sub.whatever.tk&gt;
    ServerAdmin Any@email.here
    DocumentRoot /apache2/sub/
    ServerName sub.iponu.tk
    ErrorLog /apache2/sub/logs/error.log
    TransferLog /apache2/sub/logs/transfer.log
    &lt;/VirtualHost&gt;

    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.

    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.

    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.
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  6. #6
    Yeah, I will go into adding mySQL db's and cgi-bins and other intresting stuff in another tutorial.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    1,050
    thanks for the tut JChostingadmin i dont have a use for it such az yet but i have bookmarked it for future reference tut`s like these come in handy at 1 point or another
    By the sacred **** of the sacred psychedelic tibetan yeti ....We\'ll smoke the chinese out
    The 20th century pharoes have the slaves demanding work
    http://muaythaiscotland.com/

  8. #8
    Senior Member
    Join Date
    Jul 2001
    Posts
    281
    JCHostingAdmin: I think a more interesting concept in Apache which is done quite simmarly, is named based Virtual Hosting. Apposed to IP based which is what you explained. With name based virtual hosting you can have one IP address serve many many websites. We did this for about 10 low usage sites on the web at my old office to conserve IP's.

    I wouldn't recommend doing this with high usage sites, because of the load it would probaly create.
    You\'re either a 0 or a 1, alive or dead

  9. #9
    Senior Member
    Join Date
    Jul 2002
    Posts
    167
    <VIRTUALHOST 24.44.33.2:80>
    ServerName test.antionline.com
    ServerAlias test.antionline.com www.test.antionline.com
    ServerAdmin admin@antionline.com
    DocumentRoot /var/www/html
    ErrorLog logs/-error_log
    TransferLog logs/-access_log
    </VIRTUALHOST>

    You may need to add an A record to DNS. If you use DNS2GO then they will automatically forward all subdomains to you without the A record. Don't forget to add it to the /etc/hosts file.

    One cool thing that I have seen done is a redirect from the httpd.conf file to a windows 2000 server internaly.

    Nate

  10. #10
    Kwiep
    Join Date
    Aug 2001
    Posts
    924
    Thanks JCHostingAdmin and chsh.
    I was experimenting some bit with webservers and stuff. I'm going to set up one myself, and I was (believe it or not) just buisy with finding out how to make sub domains with apache, because I wanted to give some friends of mine their own directory and I wanted to make it a subdomain to make me look 1337
    Very usefull.
    Double Dutch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •