Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Subdomains in apache
PostPosted: Sat May 21, 2011 12:32 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Hello,

I know this has probably been covered numerous times, however, none of the solutions I've found on the forums here have worked for me.

As you can most likely gather, I cannot get my subdomains with Apache working. I'm running a Ubuntu Lucid server, or 10.04. I'm pretty new to this whole Linux stuff, so, it shouldn't be too difficult. I just can't find what's going on.

Anyway, as:
This Linode Library Link

assisted me in getting the Apache2 server set up. I followed it as closely as I can. Put my IP address into the ports.conf file, and disabled the default site, and created the two domain virtual host files. The only area in which I dictated were where I wanted to store the files and the actual domain names. One of which, I wish to be a subdomain of the main domain.

I will paste the Virtual host files below:

The first one is for my main domain, tjsquires.net, which works fine:
<VirtualHost 173.230.152.119:80>
ServerAdmin tj@tjsquires.net
ServerName tjsquires.net
ServerAlias http://www.tjsquires.net
DocumentRoot /home/tjsquires/tjsquiresnet
ErrorLog /home/tjsquires/tjsquiresnet/logs/error.log
</VirtualHost>

After creating this one, I went into Linode's DNS manaager and set up a CName alias, games, that links to my IP. That didn't work, so I tried an A record. None of them worked. They both when going to games.tjsquires.net, linked back to my main homepage. here's the virtual host file for the games subdomain:

<VirtualHost 173.230.152.119:80>
ServerAdmin tj@tjsquires.net
ServerName games.tjsquires.net
ServerAlias http://www.games.tjsquires.net
DocumentRoot /home/tjsquires/games.tjsquires.net
ErrorLog /home/tjsquires/games.tjsquires.net/logs/error.log
</VirtualHost>

Am I doing something completely wrong here? The linux Newbie needs your help! :)

Thank you,

Tj


Last edited by tjsquires on Sat Jun 30, 2012 6:55 pm, edited 1 time in total.

Top
   
 Post subject: Re: Subdomains in apache
PostPosted: Sat May 21, 2011 3:10 pm 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
tjsquires wrote:
Am I doing something completely wrong here? The linux Newbie needs your help! :)


At this point, I'm not seeing anything in DNS for brianna.tjsquires.net or www.brianna.tjsquires.net, so check on that first.

You said at one point you had the DNS working, but it pulled up your main host instead of the right virtualhost. Dumb question, did you restart apache after making the config change?


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 3:20 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Hi,

Whoops. When tinkering with it last night I did remove my DNS entry and have just now re-added it. I added it as a CNAME alias as I have been instructed to do as to some guides I've read.

I can redo it to an A record if need be, however, I've done this before and no luck

Yes. I have reloaded, and even restarted, apache. I will do that now again just to be safe.

It saw no errors with the config files and seems to have been restarted successfully. To cover all my bases, I reloaded apache's settings with /etc/init.d/apache2 reload as well.

Tj


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 5:34 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
Does /etc/apache2/ports.conf have a "NameVirtualHost" entry, like

NameVirtualHost *:80

edit: I guess in your case it should be

NameVirtualHost 173.230.152.119:80


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 5:39 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Hi,

Here is my ports.conf file. In the guide I read it said to replace some lines with my IP, which I have done. Is this where the problem lies? File is below.


# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost 173.230.152.119:80
Listen 80

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 5:45 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
Since something similar came up recently, have a gander at this:

viewtopic.php?t=7031&highlight=

maybe it helps...


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 6:01 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Hi,

I had a look at that other post. My cache is turned off, and I've had several other people test out the subdomain to no luck. I looked at the name based virtual host documentatiot and the virtual hosts look like I believe they should. See my first post if you need to see them. I know I'm going to feel like an idiot once this is figured out, but...at least I'll learn something. I do wonder though if there is issues with the files in /etc/apache2/sites-available. Are they not even beeing looked at properly? I guess what I'm trying to get at is when someone types in my subdomain, the http headers are only catching the main domain portion. I'm just guessing here. I'm completely baffled as to why this is happening. It all looks right to me, but, apparently, it isn't yet. :) Oh. I should state that, include /etc/apache2/sites-enabled is indeed in the apache2.conf file.

Thanks again for all of your effort. A linux newbie really really does opretiate it.

Tj


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:21 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
The subdomain brianna.tjsquires.net resolves to your server, so the problem is not with DNS; it is with your virtual host configuration.

Beyond that, in a measure of desperation, what happens if you disable the main virtual host (www.tjsquires.net) with a2dissite <sitename>? (and reload apache) What does your /etc/apache2/sites-enabled/000-default file look like?


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:28 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Now I'm slightly getting somewhere:
I have disabled tjsquires.net via sudo a2dissite tjsquires.net

Then I reloaded apache: sudo /etc/initd/apache2 reload

It gives me an error saying no virtual hosts are loaded. So, to cover my base:
sudo a2ensite brianna.tjsquires.net

It tells me that site is already loaded. So it looks to me as if something's not being seen somewhere.

I go to /etc/apache2/sites-enabled and see that brianna.tjsquires.net is deffinetly there. Just to check, I go to sites-available. all of my sites are there too.

So why would it be having trouble loading the brianna.tjsquires.net file if apache says it's enabled?

Thanks,

Tj


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:34 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
When you do a2ensite and it says a host is already loaded, that just means there is a symlink from the sites-enabled directory to the actual file in the sites-available directory. It says nothing of Apache actually load the vhost files at startup. Do you still get the error message about no virtual hosts loaded when you restart apache, and what is the exact text of that error message?


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:37 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
Go into /etc/apache2 and run this:

grep -rli "namevirtualhost" *

just to see if you have multiple namevirtualhost lines anywhere in your config.


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:39 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
I am just editing over another post. It says I've got one in ports.conf and one in apache2.conf.

Do I need to remove one of them, or change the one in apache2.conf to look the same as my ports.conf line?


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:47 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
Ideally you should only have one. Try commenting the one in apache2.conf.


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:52 pm 
Offline
Senior Newbie

Joined: Sat May 21, 2011 5:55 am
Posts: 8
Website: http://tjsquires.net
Hi,

That did the trick. Thanks a bunch for all of your help.

I suppose the lesson of the day is to read, re-read, and still re-read, the conf files, eh? Also, I believe that command will come in extremely handy.

Thanks again for all of the help I've been given - it's really opretiated.


Top
   
 Post subject:
PostPosted: Sat May 21, 2011 7:56 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
It's always something different.

BTW both your main domain and subdomain are still showing the same content for me; are you positive it is working now?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group