New help on Subdomains

Hello,

I just installed Apache with PHP, MySQL and it works fine!

I got my website running working with a domain. But now i wish to have a sub-domain.

Can anyone help me? I am running on Ubuntu (Lucid).

Thanks!

7 Replies

I assume you want a seperate site on your sub-domain? Just add a virtualhost for the subdomain after pointing the A/AAAA records for your subdomain to your linodes IP(s)

Linode Manager -> DNS Manager -> your domain -> A/AAAA Records -> Add a new A record -> Hostname: subdomain.yourdomain.com IP Address: your linode's IP -> Save changes -> Configure a vhost in apache for your subdomain the same way you configured your main domain.

Thanks for replying. I will try the advice.

Problem Configuring Name-based Virtual Hosts.

When i installed the domain, I used Apache default settings/files.

Just now i tried to add another website (sub-domain), but there was a problem. When i type in the browser "www.domain.net" it loads the 'subdomain.domain.net" folder in the server not the "domain.net".

Domain.net

 <virtualhost 106.187.45.239:80="">ServerAdmin seaarmy@live.com
     ServerName th-gaming.net
     ServerAlias th-gaming.net
     DocumentRoot /srv/www/th-gaming.net/public_html/
     ErrorLog /srv/www/th-gaming.net/logs/error.log
     CustomLog /srv/www/th-gaming.net/logs/access.log combined</virtualhost> 

Subdomain.domain.net

 <virtualhost 106.187.45.239:80="">ServerAdmin seaarmy@live.com
     ServerName minecraft.th-gaming.net
     ServerAlias minecraft.th-gaming.net
     DocumentRoot /srv/www/minecraft.th-gaming.net/public_html/
     ErrorLog /srv/www/minecraft.th-gaming.net/logs/error.log
     CustomLog /srv/www/minecraft.th-gaming.net/logs/access.log combined</virtualhost> 

A RECORDS

A/AAAA Records
Hostname    IP Address  TTL Options
106.187.45.239     Default    Edit | Remove
mail    106.187.45.239   Default    Edit | Remove
minecraft    106.187.45.239   Default    Edit | Remove
www    106.187.45.239   Default    Edit | Remove

Any suggestions? I followed the guide from Linode.

Something is messed up in your DNS (or it just has propagated yet)

C:\>ping th-gaming.net

Pinging th-gaming.net [67.215.66.132] with 32 bytes of data:

Reply from 67.215.66.132: bytes=32 time=66ms TTL=48
Reply from 67.215.66.132: bytes=32 time=682ms TTL=48
Reply from 67.215.66.132: bytes=32 time=63ms TTL=48
Reply from 67.215.66.132: bytes=32 time=64ms TTL=48

Ping statistics for 67.215.66.132:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 63ms, Maximum = 682ms, Average = 218ms

C:\>ping www.th-gaming.net

Pinging www.th-gaming.net [106.187.45.239] with 32 bytes of data:

Reply from 106.187.45.239: bytes=32 time=165ms TTL=46
Reply from 106.187.45.239: bytes=32 time=164ms TTL=46
Reply from 106.187.45.239: bytes=32 time=165ms TTL=46
Reply from 106.187.45.239: bytes=32 time=164ms TTL=46

Ping statistics for 106.187.45.239:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 164ms, Maximum = 165ms, Average = 164ms

C:\>ping minecraft.th-gaming.net

Pinging minecraft.th-gaming.net [67.215.66.132] with 32 bytes of data:

Reply from 67.215.66.132: bytes=32 time=63ms TTL=48
Reply from 67.215.66.132: bytes=32 time=64ms TTL=48
Reply from 67.215.66.132: bytes=32 time=65ms TTL=48
Reply from 67.215.66.132: bytes=32 time=62ms TTL=48

Ping statistics for 67.215.66.132:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 62ms, Maximum = 65ms, Average = 63ms

Also you don't need a "serveralias" if it's the same as "servername"

You don' t have a vhost entry for www.th-gaming.net

Did you remember to restart Apache after you changed the vhost config's?

I reload the server everytime i change the vHost.

Ok, I remove "ServerAllias" in both files.

And reloaded Apache again but this time with this error.

root@li388-239:~# /etc/init.d/apache2 reload
 * Reloading web server config apache2                                                                                [Wed Nov 09 03:39:02 2011] [warn] VirtualHost 106.187.45.239:80 overlaps with VirtualHost 1                           06.187.45.239:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Wed Nov 09 03:39:02 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
                                                                                    [ OK ]

I think it's because i accidentally remove the "default" files and then put this back instead, replacing it.

NameVirtualHost *
 <virtualhost *="">ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <directory>Options FollowSymLinks
                AllowOverride None</directory> 
        <directory var="" www="">Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                RedirectMatch ^/$ /apache2-default/</directory> 

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <directory "="" usr="" lib="" cgi-bin"="">AllowOverride None
                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all</directory> 

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <directory "="" usr="" share="" doc="">Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128</directory></virtualhost> 

Might be because of the propagation.

Or do you want me to re-install everything? And do it again.

I kinda messed it up here.

Not a bump but can't delete this post

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct