Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to give the files in my Apache Server a public domain name. How would I go about doing this?

I am running Windows 7. Apache Web Server. I am very new to this.

share|improve this question

migrated from stackoverflow.com Oct 1 '11 at 21:40

This question came from our site for professional and enthusiast programmers.

closed as off topic by Iain, Holocryptic, mailq, Wesley, MDMarra Oct 1 '11 at 22:29

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
How is your machine connected to the Internet? Through a NAT router? A modem? Something else? How is Apache installed? –  Lekensteyn Oct 1 '11 at 21:49
    
@Lekensteyn: My machine is a laptop connected by a home router. What do you mean by how is Apache installed? –  Dynamic Oct 1 '11 at 21:51
    
Did you use the Apache installer to get it installed or a software bundle like XAMPP? –  Lekensteyn Oct 1 '11 at 21:57
    
@Lekensteyn: Apache Installer –  Dynamic Oct 1 '11 at 22:05
1  
Running servers from home is consider off-topic. Please see the FAQ. –  kce Oct 1 '11 at 22:27

2 Answers 2

up vote 1 down vote accepted

Checklist for running a home server:

  • Use a static IP in your network. Dynamic addresses from DHCP are not easy to maintain
  • (NAT routers) Forward port 80 from the public to your local (static) network address. If you need your site to be reachable over https too, you also need to forward port 443.
  • Firewall: allow incoming traffic to port 80 (and 443 for https)
  • DNS: set type A record with your public IP as value. The name can be empty (which would point to example.com, a wildcard * (whateverhere.example.com), and subdomains like www and sub (www.example.com and sub.example.com)

Answer for a local homeserver

Since you're running Win7, I'll assume a home environment. If you're fine with a local domain name like example.local, you can edit your hosts file to make example.local point to your server.

For that to work, you need to edit C:\Windows\System32\drivers\etc\hosts (requires administrative privileges) and add a line for the domain:

127.0.0.1 example.local www.example.local

You also need to edit your server configuration (httpd.conf in the configuration directory of your Apache installation) and change ServerName localhost (or whatever default was chosen during installation) to ServerName example.local and add ServerAlias www.example.local.

Restart your webserver and you'll be ready to use your new local domain.

If the above did not work (i.e. you just get "localhost" back as domain name in the footer), you've probably a Virtual Host setup. Locate the configuration file in your Apache installation and edit the related section. See http://httpd.apache.org/docs/2.2/vhosts/examples.html

share|improve this answer
    
I will edit my question to reflect this, but I already own a domain name, and want the files in my home web server to be reached by a public domain name. –  Dynamic Oct 1 '11 at 21:47

You need to do a few things:

  • Get DNS working. Whoever you registered your domain with will probably do this. Set www.yourdomain to point at your IP. You have a static IP, right? If not, you'll have trouble pointing your domain at it.
  • Convince your network to route ports 80 and 443 to your machine. You're almost certainly behind some kind of firewall, so make it allow ports 80 and 443 to your machine. This could be a NAT change if you're behind a home router.
  • Tell Apache on your machine where to find the files you want to serve up. You should do this first and test it using a browser on another machine on your network.

Those are all pretty generic answers, but with the data you've given it's hard to be more specific.

share|improve this answer

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