How to link an html page on Apache to a domain name?

12,037

Solution 1

Unfortunately, it is not very simple.

First off, you need some form of hosting. Since you indicate that you want to serve the page from your local machine, that becomes your hosting.

Next, you need to point your domain to your host. Most paid hosting services provide nameservers to point your domain to. In your case, however, you will need to obtain a static IP from your ISP, and manually create an A record using Godaddy's control panel, which points your domain to your static IP.

Then you will need to forward port 80 to the computer running the webserver. Also, since this computer is now publicly accessible on port 80, make sure you are running the latest version of the webserver to reduce any security risks.

Finally, in some home network setups, typing in the domain name from the same subnet as the webserver may not work. Be sure to test your website using an external connection.

Also, DNS changes may take up to 48 hours to propagate across the internet. If your website does not work immediately, wait for some time before trying again. I have noticed that Google's Public DNS servers (8.8.8.8, 8.8.4.4) usually update withing 15 minutes, try using those to test your domain.

Solution 2

You'll need to spend some time reading the Apache HTTPd documentation so that you can configure it to meed your specific needs. Online, there is an example of a simple VirtualHost setup that help to get you started:

In taking from that example, I think you could start out with a much simpler version of it, which I'm posting here:

<VirtualHost 127.0.0.1:80>
  ServerName            www.example.com
  ServerAlias           example.com
  ServerAdmin           [email protected]
  DocumentRoot          /internet/com/example/www
  ScriptAlias /cgi-bin/ /internet/com/example/cgi-bin
  CustomLog             /internet/com/example/logs/access.%Y-%m.log combined
  ErrorLog              /internet/com/example/logs/errors.%Y-%m.log
  <Location />
    AddOutputFilter INCLUDES .html
    Options +Includes +ExecCGI
    DirectoryIndex index.html
    ErrorDocument 404 /404.html
  </Location>
</VirtualHost>

In the above example, it is assumed that you have the following directories created on your system before-hand (your HTML files belong in "www"):

/internet/com/example/www/
/internet/com/example/logs/
/internet/com/example/cgi-bin/

After you have Apache HTTPd configured, and you've tested it by browsing to http://127.0.0.1/ (localhost), you'll need to do the following:

  1. Determine your public IP address (it should be static for running a web server)
  2. Change "127.0.0.1" in the configuration sample above to this IP address
  3. Set up "A" and/or "AAAA" records on your DNS server with this IP address
Share:
12,037

Related videos on Youtube

user882903
Author by

user882903

Updated on September 18, 2022

Comments

  • user882903
    user882903 over 1 year

    I just registered a domain name via godaddy.com. Is there some help for a beginner somewhere on how to serve my website on the domain.

    To begin with, I want to set it up to display an HTML page running on my local machine via Apache.

    How can I do that?

    • Admin
      Admin about 12 years
      when i tried to visit my website with full url ex: ( www.example.co.in)i am getting lists of files like Index of / exampl.html cgi-bin/ google22c029ceaa9a24f6.html but i just wanted to make display of exampl.html for public when they going enter website adds www.example.co.in for this what i have to do.. plz plz give me solutions. Thank you.