Sign in with
Sign up | Sign in
Your question
Solved

Creating Subdomains on Debian with Apache2

Last response: in Linux/Free BSD
Share
January 8, 2012 7:01:20 AM

Howdy all,

I've been working on trying to set up some sub domains on my web server. I'm working on getting everything I want installed/configured, and then am gonna expose it to the elements. It'll be hosting a website/blog for personal use (which will be the root directory, aka www.mydomain.com), and then have a few sub domains (just because that's how I want it, I know I could use directories as well) for various tools I use, such as svn, a dev directory, and whatever else I come up with. For the sake of just trying to get things working, I'll just go with the /var/www/dev/ directory right now, which I want to be accessible as dev.mydomain.com.

My setup is just a basic Debian 6 installation, of course with Apache2 and number mods/libs. I haven't changed any settings from default yet. I'm also not sure if my issues are arising from trying to access it on the local network, or if things just aren't working. I've spent some time Googleing, but nothing seems to be working.

I followed an example posted on a forum, which is as follow:

  1. NameVirtualHost *:80
  2.  
  3. <VirtualHost *:80>
  4. ServerName localhost
  5. DocumentRoot /var/www/
  6. </VirtualHost>
  7.  
  8. <VirtualHost *:80>
  9. ServerName dev.localhost
  10. ServerAlias dev.*
  11. DocumentRoot /var/www/dev/
  12. </VirtualHost>


Again, I'm not sure if this is the proper way to do things, but it makes sense in my head if that's worth anything :D  I posted this in the httpd.conf file as recommended (which was empty from default), and restarted the server. There were no errors, although there were some warnings. All the pages and directories loaded fine, but the sub domain did not work. Note at this time I'm connecting via "192.168.0.14". Do note that even with the default config I am getting the following:

Quote:
root@debian6: /etc/apache2# /etc/init.d/apache2 restart
Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName


... everything seems to be working just fine.

Anyways, I haven't done a whole lot of web server stuff before, so I really just don't know where to go from here. Just looking for some guidance :) 

Thanks all,


- Jesse
January 8, 2012 8:08:34 AM

You say that you are connecting via 192.168.0.14. Does this mean that you are typing the IP address in as the location? If so, this means that you will reach the default server, not the virtual one. What you need to do is to create an alias in your DNS pointing dev.mydomain.com to www.mydomain.com and then connect with that name (for virtual servers Apache checks the name that you are connecting to, not just the IP address). And you obviously need the correct names in your VirtualHost entries. The other way to do it is to use different ports, but that's less convenient.

Or have I completely misunderstood your problem?
January 8, 2012 5:02:26 PM

Ijack said:
You say that you are connecting via 192.168.0.14. Does this mean that you are typing the IP address in as the location? If so, this means that you will reach the default server, not the virtual one. What you need to do is to create an alias in your DNS pointing dev.mydomain.com to www.mydomain.com and then connect with that name (for virtual servers Apache checks the name that you are connecting to, not just the IP address). And you obviously need the correct names in your VirtualHost entries. The other way to do it is to use different ports, but that's less convenient.

Or have I completely misunderstood your problem?


Yes, I'm just typing the local IP into the address bar of my browser; I was also trying to add the sub domain to the local IP.

The thing is that I haven't actually purchased a domain name yet, so I was just trying to get things working locally without one. I'm not sure if this is possible or not. If it'd be easier to use a domain name, I can just purchase one and try with that.

Thanks,


- Jesse
Related resources

Best solution

January 8, 2012 5:28:26 PM
Share

You can test it without a domain. Just put names into your hosts file pointing to the IP address of your server and then use those names for your virtual servers.

I guess there is another way of doing this, which would be to assign multiple addresses to your NIC and then set each server to listen on a specific address. But having several names assigned to the same IP address is simplest.
January 8, 2012 5:29:02 PM

(Accidental multiple post.)
January 8, 2012 5:29:56 PM

(Ditto.)
January 8, 2012 8:23:19 PM

Brilliant, got it working! Thank you very much, probably wouldn't have ever figured out that host file stuff :D 
January 8, 2012 10:19:10 PM

Best answer selected by Pyroflea.
January 10, 2012 3:37:14 PM

What would you do with the IP?
January 10, 2012 4:09:52 PM

Personally, nothing. I just don't have that level of skill. Perhaps a little look-up and cross referencing to locate them and add them to the blacklist is my limit.

'Others' with more skills than mine however used to enjoy giving spammers a little probing and perhaps a little injection to calm them down. It's probably a good thing it's not happening nowadays.
January 10, 2012 11:02:58 PM

I have a feeling there have been some posts deleted since I checked this thread last? :D 
January 11, 2012 1:29:57 AM

Look at it this way, I doubt the removed post was made by a Rabbi. [/pork products]
!