Find the answer to your Linux question:
Results 1 to 3 of 3
I have tried to set up sub domains using Apache Webserver - Virtual Hosts, however I cannot get them to work. The directoryfor the sub-domian is different from the main ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    4

    Sub Domains not working!


    I have tried to set up sub domains using Apache Webserver - Virtual Hosts, however I cannot get them to work.

    The directoryfor the sub-domian is different from the main domain does this make a difference?

    What could I try to get it to work?

    Thanks in Advance for any help!

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Posts
    2
    There are two parts to this. One by itself, however perfect, cannot work without the other.

    1: Configure Apache’s virtual host.

    Here is an example of the virtual host of "example.com" and its sub domain "bar.example.com"

    Code:
    <VirtualHost *:80>
        DocumentRoot /var/www/example.com/html
        ServerName example.com
        ServerAlias www.example.com
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot /var/www/bar.example.com/html
        ServerName bar.example.com
    </VirtualHost>
    Make DocumentRoot whatever you want. Mine is merely an example. The location is irrelevant as long as the path exists.

    2: Make an entry for this sub domain on the Domain Name Server for your domain name.

    I use Fedora 7’s GUI to configure mine, but all you need is to add an A record pointing “bar.example.com” to your server’s IP address. This A record is supposed to be in your “example.com” zone file where the A record for “example.com” is also located. If that is not familiar to you, please refer to google and many other resources on DNS servers.

    After searching google myself, I find that a CNAME record would also work if the IP address is the same. For more information visit:
    Subdomain Configuration - How To Setup A Sub Domain - WebsiteGear

    Or google:
    dns subdomain - Google Search

    And good luck.

  3. #3
    Just Joined!
    Join Date
    Jan 2008
    Posts
    28

    Apache virtual hosts

    I'm running several named virtual hosts using LAMP (Linux/Apache/MySQL/PHP). Some have the same directory and some have different directories. Make sure you have a Directory section or the virtual host document root.

Posting Permissions

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