Web Servers - Advantages

Discusses the advantages of using a web server within a web development environment.

While you can certainly create and test HTML pages on your local computer without a web server, most web professionals use their own web server.

There are many advantages to using a web server within your development environment. Of course, in a production hosting environment, a web server is essential. And, depending on your website, a web server could indeed be essential in your development environment.

When I say "development environment", I'm referring to a copy of your website, usually on your local machine, that you use to perform updates before you commit them to the live (production) environment.

In practice, you could have many copies of your website for different purposes (such as testing, training, protypes etc), but let's just call it "development environment" for now.

Here are some advantages of using a web server within your development environment:

Viewing HTML Files Without a Web Server

When someone learns how to code HTML, chances are, one of the first things they learn to do is how to view their (newly created) HTML file. They will learn that you can simply double click on the HTML file, and this will launch it in their web browser. And from that point on, they can view their web page/website as it was intended to be viewed.

Here are some examples of what the URL could look like when viewing a web page without a web server:

These examples are using the file protocol in order to display the files.

Viewing HTML Files With a Web Server

One problem with the above method is that, you're not viewing the website using the HTTP protocol (you're using the file protocol instead).

Now, this isn't normally a problem if you're only using client side languages such as HTML, CSS, and client-side JavaScript. But it is a problem if you're trying to use a server-side language such as PHP, ColdFusion etc.

Also, even if you're not using a server-side language, it could still cause you problems with developing a website that behaves exactly how it should on the web.

When you view a web page via a web server, the URL begins with http://. Also, the URL will consist of either an IP address or a domain name/host name.

Here are some examples of what the URL could look like when viewing a web page via a web server:

When you first set up a web server, you can usually navigate to your default web site typing http://localhost or http://127.0.0.1. When you add more websites, you'll need to create your own URLs for them (via a DNS server or Hosts file), then assign that URL to your websites via your web server.