LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2009, 12:45 PM   #1
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Rep: Reputation: 15
Apache subdomain help


It may make more sense for me to post this in an Apache forum but I have gotten really great help from this community recently so I figured I'd try here first.

I am running CentOS 5 and Apache 2.2.3 and I am trying to set up a subdomain. I have read several web pages on the matter and tried several different things with no success. I have custom DNS set up at dyndns.com and before I started messing with subdomain stuff everything was working fine. For these purposes we'll say my domain is mydomain.net and I want the subdomain to be admin.mydomain.net. Here is what my /etc/hosts file looks like:

#Start File ----
127.0.0.1 mydomain.net localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
127.0.0.1 admin.mydomain.net
#End File ----

...and here are the changes I made to /etc/httpd/conf/httpd.conf:

I uncommented NameVirtualHost *:80

and added this to the end of the file:

<VirtualHost *:80>
DocumentRoot /var/www/admin
ServerName admin.mydomain.net
ServerAlias admin.mydomain.net
</VirtualHost>


I then created a directory called "admin" in /var/www and put a simple hello world php file there. Now on the internet when I go to admin.mydomain.net I get Server not found "Firefox can't find the server at admin.mydomain.net." and when I go to mydomain.net I get the hello world that I put in the admin directory.

Again, before I started messing with this subdomain business I could go to mydomain.net and it would show the website just fine. What am I doing wrong?!?

As always, help is greatly appreciated!

Thanks!
 
Old 11-24-2009, 02:41 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
You also need to declare a virtualhost for your main domain.
 
Old 11-24-2009, 03:01 PM   #3
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rweaver View Post
You also need to declare a virtualhost for your main domain.
Okay, I added a VirtualHost for my main domain as well so now the end of the httpd.conf file looks like this:

<VirtualHost *:80>
DocumentRoot /var/www/admin
ServerName admin.mydomain.net
ServerAlias admin.mydomain.net
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName mydomain.net
ServerAlias mydomain.net
</VirtualHost>


I restarted Apache and I still get the same issue. Server not found at admin.mydomain.net and the /var/www/admin/index.php file when I go to mydomain.net instead of the /var/www/html/index.php file I am expecting.

Also, I posted here http://www.apacheforum.com/showthread.php?t=167605 for additional help from some apache uses.
 
Old 11-24-2009, 04:11 PM   #4
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Okay, I think I've made some progress...kinda. I moved my admin directory from /var/admin to /var/www/html/admin

Now when I visit mydomain.net I get the index.php file in /var/www/html like I want/expect and when I visit mydomain.net/admin I get the index.php file in /var/www/html/admin like I guess I would expect. So how do I get admin.mydomain.net to serve me the /var/www/html/admin/index.php like I want? I still get a Server Not Found error when I try to visit admin.mydomain.net.

...by the way, the forum at http://www.apacheforum.com/ is so flooded with spam that I don't see myself getting any help there. Is there another forum you guys would suggest I post to for Apache help?

Last edited by Orange Sunshine; 11-24-2009 at 04:13 PM.
 
Old 11-24-2009, 04:23 PM   #5
neeraj_sriva
LQ Newbie
 
Registered: Nov 2008
Posts: 6

Rep: Reputation: 1
Is your subdomain resolving ? What you get when you run nslookup admin.mydomain.net ?
 
Old 11-24-2009, 04:33 PM   #6
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by neeraj_sriva View Post
Is your subdomain resolving ? What you get when you run nslookup admin.mydomain.net ?
when I type admin.mydomain.net under nslookup I get:

Server: 208.67.222.222
Address: 208.67.222.222#53

Non-authoritative answer:
Name: admin.mydomain.net
Address: xx.xxx.xxx.xxx

and then when I type mydomain.net (which is resolving fine) under nslookup I get:

Server: 208.67.222.222
Address: 208.67.222.222#53

Non-authoritative answer:
Name: mydomain.net
Address: xx.xxx.xxx.xxx


I have no idea what the 208.67.222.222 addresses are but the xx.xxx.xxx.xxx are matching for both and are the correct ip address to my machine. Does that mean it is resolving correctly? Also, I did the nslookup on the web server that is hosting the site. Is that what I was supposed to do? Or do I need to do it on another machine?

Last edited by Orange Sunshine; 11-24-2009 at 04:35 PM.
 
Old 11-24-2009, 04:38 PM   #7
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Orange Sunshine View Post
Also, I did the nslookup on the web server that is hosting the site. Is that what I was supposed to do? Or do I need to do it on another machine?
Just to be sure I tried it on another machine and I got the same results for Non-Authorative answer but different addresses for the first Server:
Address: if that makes any sense.
 
Old 11-24-2009, 05:03 PM   #8
neeraj_sriva
LQ Newbie
 
Registered: Nov 2008
Posts: 6

Rep: Reputation: 1
The ip should match at the machine where you are opening your website in Firefox, if both sub domain and main domain are hosted on same IP. Also, check if you can open your page at web server itself, if it is working there then some problem with name resolution at other machine.
 
Old 11-24-2009, 05:10 PM   #9
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by neeraj_sriva View Post
The ip should match at the machine where you are opening your website in Firefox, if both sub domain and main domain are hosted on same IP. Also, check if you can open your page at web server itself, if it is working there then some problem with name resolution at other machine.
Well, something magic happened and everything is working correctly now. I didn't make any changes at all since the last time I checked and it wasn't working. Oh well, I'm not complaining.

Thanks for the help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache redirect to a different subdomain uglyoldbob Linux - Server 0 08-18-2009 06:57 PM
Apache - subdomain on second machine coobav Linux - Server 1 07-08-2009 03:48 AM
Apache 1.3.33 and subdomain fai Linux - Software 1 07-15-2005 04:49 AM
subdomain and apache ziggie216 Linux - Newbie 1 11-12-2003 03:36 PM
Subdomain and apache! eXor Linux - Networking 1 10-13-2002 06:49 PM


All times are GMT -5. The time now is 12:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration