I am relatively new to Ubuntu Linux and I am struggling to figure out the basic set-up of hosting a domain name at home with Apache2. I understand that you have to change your IP from dynamic to a static IP Address but I am not sure how you achieve that step.

I am looking for some assistance on this on how to enable self signing certificates, make the domain name resolve on the Internet from hosting the website on the web server, enabling protected directories and the basic commands of accessing the directory where the website files can be uploaded and available on the World Wide Web.

closed as not a real question by Tom Brossman, John S Gruber, Florian Diesch, Mitch, Ringtail Sep 10 '12 at 4:28

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • One question at a time. I read about a half dozen in there. – RobotHumans Sep 10 '12 at 1:16

I have done this because as a web developer, I like to work on sites on my home server then upload the site to the final hosting company after it's working. So, to allow the client to see and approve changes, I got a domain from dynDNS (dyn.com) for $20/year. There are similar systems for free, and dynDNS used to have a free account, but I don't think they do anymore. But I chose the dynDNS Pro, because $20/year is pretty cheap, and you get multiple domain names and wildcard domains.

What it Does

This service works by giving you a choice of existing domain names they own, such as yourname.homelinux.net, etc. For example, you can choose one called somename.homelinux.net, and then you can instantly create a unique site called xxx.somename.homelinux.net without registering it, and in Apache, set up a domain with that name. That's all it takes to create a new domain. You can also register other domains. There may be a more premium service that allows you to use your existing domain name, and have it hosted with them, but I don't need that.

How it Works

They have an app that updates your dynamic IP periodically. So, you have a constant domain name, but the IP it points to can change.

How to Set Up Apache on Ubuntu

Apache can take a domain name and use it to access a local website in any given directory using Virtual Hosts. The IP address doesn't matter, and you can have any number of virtual hosts using the same IP address; it's the name that matters, not the address.

This done by making an entry in a configuration file, at /etc/apache2/sites-enabled/000-default. I'm assuming the default configuration; I think you could have more than one of these files, but I haven't done this.

In order for this to work, you need to have a module enabled called rewrite.load. This module is in /etc/apache2/mods-available, and to use it, you would create a symbolic link in the directory /etc/apache2/mods-enabled (from the mods-enabled directory, enter "ln -s ../mods-available/rewrite.load").

OK, once this is done, then for any domain name you want to resolve on your local system, you create a multi-line entry in the configuration file (000-default). I like examples better than directions, so here is an example:

Setup of /etc/apache2/sites-enabled/000-default

Assume you have a local website, and you use dynDNS with a name like mycoolsite.homelinux.com. Further assume that the site's location is in /var/www/mycoolsite (it can be anywhere, including your home directory). Then, the following entry at the end of your configuration file would make this work (assumes port 80, the conventional web port):

<VirtualHost *:80>
    <Directory /var/www/mycoolsite>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    DocumentRoot /var/www/mycoolsite/
    ServerName mycoolsite.homelinux.com

Note that this is not the only set of parameters that work. The Directory section is not needed if you don't need to change anything from the defaults, but I always just include it, and it's been a while since I figured out exactly why. But it always works, so I leave it be.

This same setup can be used to make a "fake" development site on localhost, if you make an entry in your hosts file on any machine that will access it, assigning a name to the IP (either localhost, or the IP address of the server on the LAN). You can have a number of these aliases in your hosts file, all with the same IP.

I don't fully understand what you are asking for the second part of your question. If you want to further elaborate, I'll try to help. It may be that the method I suggested isn't what you are looking for. If not, I'm sorry. Let me know if you have questions.

  • Thank you for you reply. I am wanting to actually register the domain using Ubuntu with the Apache web server but I don't know the file to use to assign a website address and how to host that domain using the DNS server using the commands without using a website hosting company. I am aware that you can change your dynamic IP to a static IP address by simply changing information on a file. If I can register the domain name on Apache from home without using any service to help that would be better and to make sure it resolves on the Internet. – Andrew McIntyre Apr 1 '12 at 17:17
  • You can't change a dynamic IP to a static IP for your WAN IP address, just for your LAN IP address. But this won't be visible outside of your LAN, because it is not unique. To change your WAN IP address from dynamic to static, you need to change it with your ISP, and probably pay more. But it will cost more than most shared web hosting. – Marty Fried Apr 1 '12 at 17:27
  • If you were to get a static IP address, then in order to register your domain name, you would want to use a domain registrar and a DNS provider, which the registrar usually does for free. I don't know if you can bypass this part, or why you would even want to, since you can get free DNS service if you want. But with a static IP, you can point the domain to your server, if desired. – Marty Fried Apr 1 '12 at 17:31
  • I understand the set up of IP addresses now. So if I was wanting to still have a domain name with a domain like www.example.com so it is available on the web and using dynDNS for the IP Address how would I do that in terms of set up on Ubuntu. – Andrew McIntyre Apr 1 '12 at 17:34
  • I suggest that you go to dyn.com, where you can sign up for a free trial of services. I don't use my own domain names for my home server; they have hundreds to choose from, and I don't mind using one of theirs (I mainly use myname.homelinux.net). They also have names like homeftp.com, from-ny.com (or any state), lighter ones such as isa-geek.com, and many others. If you want to use your own domain name, you would probably use them or another DNS provider that handles dynamic DNS. I haven't done this, but I'd guess all of them probably have you run an app to update their server. – Marty Fried Apr 1 '12 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.