Solved

Creating Subdomains on Debian with Apache2

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:

[cpp]NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/
</VirtualHost>

<VirtualHost *:80>
ServerName dev.localhost
ServerAlias dev.*
DocumentRoot /var/www/dev/
</VirtualHost>[/cpp]

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
12 answers Last reply Best Answer
More about creating subdomains debian apache2
  1. 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?
  2. 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
  3. Best answer
    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.
  4. (Accidental multiple post.)
  5. (Ditto.)
  6. Brilliant, got it working! Thank you very much, probably wouldn't have ever figured out that host file stuff :D
  7. Best answer selected by Pyroflea.
  8. I miss the days when Jake just used to give us the IP of little gits like this...

    AMDFG - You might want to check his full post history as I'm sure this will be cross section. (see also http://www.tomshardware.co.uk/forum/238018-38-change-default#t870258 )
  9. What would you do with the IP?
  10. 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.
  11. I have a feeling there have been some posts deleted since I checked this thread last? :D
  12. Look at it this way, I doubt the removed post was made by a Rabbi. [/pork products]
Ask a new question

Read More

Web Server