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:
- Your local website behaves more like the live one. For example, you can configure directory security, test your custom error pages etc before commiting them to the production environment.
- You can use server-side scripting languages such as PHP and ColdFusion.
- Allows you to standardize your coding. For example, you can use root-relative paths for your image references and hyperlinks (eg, /directory/image.gif). In other words, your paths can represent the website structure, rather than the directory structure of your computer.
- Knowledge. The knowledge you gain from using your own web server will help you understand how it works in the live environment. This will most certainly help you when you need to communicate with your hosting provider - you'll be able to use terminology that makes it easier for them to understand your request/issue.
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).
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.