Subdomains in apache
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:
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:
ServerName tjsquires.net
ServerAlias
DocumentRoot /home/tjsquires/tjsquiresnet
ErrorLog /home/tjsquires/tjsquiresnet/logs/error.log
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:
ServerName games.tjsquires.net
ServerAlias
DocumentRoot /home/tjsquires/games.tjsquires.net
ErrorLog /home/tjsquires/games.tjsquires.net/logs/error.log
Am I doing something completely wrong here? The linux Newbie needs your help!
Thank you,
Tj
15 Replies
@tjsquires:
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
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?
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
NameVirtualHost *:80
edit: I guess in your case it should be
NameVirtualHost 173.230.152.119:80
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
the VirtualHost statement in /etc/apache2/sites-available/default-ssl
to # Server Name Indication for SSL named virtual hosts is currently not
supported by MSIE on Windows XP.
Listen 443
maybe it helps…
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.
Thanks again for all of your effort. A linux newbie really really does opretiate it.
Tj
Beyond that, in a measure of desperation, what happens if you disable the main virtual host (
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
grep -rli "namevirtualhost" *
just to see if you have multiple namevirtualhost lines anywhere in your config.
Do I need to remove one of them, or change the one in apache2.conf to look the same as my ports.conf line?
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.
BTW both your main domain and subdomain are still showing the same content for me; are you positive it is working now?