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! |
You also need to declare a virtualhost for your main domain.
|
Quote:
<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. |
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? |
Is your subdomain resolving ? What you get when you run nslookup admin.mydomain.net ?
|
Quote:
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? |
Quote:
Address: if that makes any sense. |
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.
|
Quote:
Thanks for the help! |
All times are GMT -5. The time now is 11:46 PM. |