If you've been learning how to create websites via the Quackit tutorials, you will be well on your way to developing websites. You may already be developing websites. This web server tutorial explains some of the benefits of running your website through a web server.
Who Should Read This Tutorial?
This tutorial is recommended for anyone who is serious about developing websites. It would be great if you have some knowledge of HTML, CSS, and even JavaScript but this is not essential. It's not essential because this tutorial is very high-level. It does not go into technical details - it's purpose is to provide you with an understanding of where web servers fit within a web development/web hosting environment.Oh, and if you ever wondered where the "http://..." bit comes from when you view a website, read on!
What Is A Web Server?
A web server is a piece of software that enables a website to be viewed using HTTP. HTTP (HyperText Transfer Protocol) is the key protocol for the transfer of data on the web. You know when you're using HTTP because the website URL begins with "http://" (for example, "http://www.quackit.com").You might be thinking "I always thought a web server was a special, high-powered computer". Well, you'd be right too. Some high-powered computers are referred to as web servers as they have been built with web hosting in mind. But in most cases, when someone refers to a web server, they are referring to a piece of software that you install on a computer.
What Does a Web Server Look Like?
That depends on which web server you choose to install. Here's an example of Microsoft Internet Information Services (IIS) 5.1 looks like:The left pane represents the various websites, FTP sites, and SMTP virtual servers. When an item in the left pane is selected, the contents are displayed in pane on the right hand side.
In the above screenshot, there is one website (called "Default Web Site"), one FTP site (called "Default FTP Site"), and one SMTP virtual server (called "Default SMTP Virtual Server").
You can right click on an item to display it's properties. For example, you can right click on "Default Web Site" to display (and configure) the properties of that website.
Do I Need A Web Server?
If you maintain your own web site I recommend you install a web server on your own development machine. That way you can configure your development environment to be closer to your live environment.Also, if you intend to use server-side technologies such as PHP or ColdFusion, you will definitely need a web server.
Web Servers are Easy!
You might also be thinking that web servers are way too advanced for you - that they are only used by professional web developers and/or hosting companies. Please don't think that!Think of a web server as simply another piece of software you can install on your machine. Once you install it, you can configure it to suit your needs.
And, depending on your computer set up, you may even find that you already have a web server on your machine.
Now, having declared that "web servers are easy!", there are many advanced topics regarding web servers. I won't be going into any detail in this tutorial. You can get a web server up and running on your machine with a minimum of technical knowledge. Then once you've done that, you'll start to become familiar with the various options available to you. Then if required, you can research the more advanced topics to suit your needs (such as security, load issues, logging etc)
Web Servers - Advantages
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 (i.e. "/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:
- file:///C:/Documents%20and%20Settings/Homer%20Simpson/My%20Documents/index.html
- file:///C:/Inetpub/wwwroot/index.html
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:
- http://127.0.0.1
- http://localhost
- http://www.quackit.com
- http://dev.quackit.com
Web Servers - Features
There's a common set of features that you'll find on most web servers. Because web servers are built specifically to host websites, their features are typically focussed around setting up and maintaining a website's hosting environment.
Most web servers have features that allow you to do the following:
- Create one or more websites. (No I don't mean build a set of web pages. What I mean is, set up the website in the web server, so that the website can be viewed via HTTP)
- Configure log file settings, including where the log files are saved, what data to include on the log files etc. (Log files can be used to analyse traffic etc)
- Configure website/directory security. For example, which user accounts are/aren't allowed to view the website, which IP addresses are/aren't allowed to view the website etc.
- Create an FTP site. An FTP site allows users to transfer files to and from the site.
- Create virtual directories, and map them to physical directories
- Configure/nominate custom error pages. This allows you to build and display user friendly error messages on your website. For example, you can specify which page is displayed when a user tries to access a page that doesn't exist (i.e. a "404 error").
- Specify default documents. Default documents are those that are displayed when no file name is specified. For example, if you open "http://localhost", which file should be displayed? This is typically "index.html" or similar but it doesn't need to be. You could nominate "index.cfm" if your website is using ColdFusion. You could also nominate a 2nd choice (in case there is no index.cfm file), and a 3rd choice, and so on.
Example Web Server
Here's an example of the "Properties" dialog box from Microsoft IIS. This box is displaying the properties for a single website. To display the box, I simply right-clicked on the website and selected "Properties".You can see that the website has been configured to use the local path of c:\inetpub\wwwroot. What this means is that when you update your website, you need to place your files and folders within that directory. As soon as you do that, your changes will take effect on your website. Of course, if this is your development environment, you can simply edit the files straight from that directory.
How Web Servers Work
Whenever you view a web page on the internet, you are requesting that page from a web server. When you type a URL into your browser (for example, "http://www.quackit.com/html/tutorial/index.cfm"), your browser requests the page from the web server and the web server sends the page back:The above diagram is a simplistic version of what occurs. Here's a more detailed version:
- Your web browser first needs to know which IP address the website "www.quackit.com" resolves to. If it doesn't already have this information stored in it's cache, it requests the information from one or more DNS servers (via the internet). The DNS server tells the browser which IP address the website is located at. Note that the IP address was assigned when the website was first created on the web server.
- Now that the web browser knows which IP address the website is located at, it can request the full URL from the web server.
- The web server responds by sending back the requested page. If the page doesn't exist (or another error occurs), it will send back the appropriate error message.
- Your web browser receives the page and renders it as required.
Multiple Websites
A web server can (and usually does) contain more than one website. In fact, many hosting companies host hundreds, or even thousands of websites on a single web server. Each website is usually assigned a unique IP address which distinguishes it from other websites on the same machine. This IP address is also what the DNS server uses to resolve the domain name.It is also possible to configure multiple websites without using different IP addresses using host headers and/or different ports. This can be useful in a development environment and is quite easy to do.
Page Not Found
If the requested page isn't found, the web server sends the appropriate error code/message back to the client.You can create user friendly error messages, then configure your web server to display that page instead of the usual error page. This can add a nice touch to your website. How many times have you (or even worse, your visitors) encountered a plain white page with some cryptic error message on it?
It's very easy to create custom error pages, then configure your web server to use them.
Default Documents
If you've ever created a website, you may have found that if you have an "index" file (index.html for example), you don't need to specify the name of the file. For example, the following URLs both load the same page:- http://www.quackit.com/html/tutorial
- http://www.quackit.com/html/tutorial/index.cfm
SSL Certificates
You can apply SSL certificates against a website via the web server. First you need to generate the certificate either by yourself (i.e. using a certificate generator), or by a Certificate Authority (CA). Then, once it has been generated, you apply it to your website via your web server. Applying an SSL certificate to a website is a straight forward task.Once you've applied an SSL certificate against a website, you can navigate it using HTTPS (as opposed to HTTP). HTTPS encrypts any data that is transferred over the internet. This reduces the possibility of some malicious person being able to read your users' sensitive information.
To navigate a website using HTTPS, you simply replace the HTTP with HTTPS at the start of the URL in your browsers' location bar ("https://www.quackit.com")
Web Servers - Examples
This page contains information about three of the most popular web servers on the web.Apache HTTP Server
Apache HTTP Server (also referred to as simply "Apache") has, at the time of writing, been the most popular web server on the web since 1996. Apache is developed and maintained by the Apache Software Foundation, which consists of a decentralized team of developers. The software is produced under the Apache licence, which makes it free and open source.Apache is available for a range of operating systems, including Unix, Linux, Novell Netware, Windows, Mac OS X, Solaris, and FreeBSD.
Apache HTTP Server website: http://httpd.apache.org
Microsoft Internet Information Services (IIS)
IIS is, at the time of writing, the second most popular web server on the web. It is however, gaining market share, and if the current trend continues, it won't be long before it overtakes Apache.IIS comes as an optional component of most Windows operating systems. You can install IIS by using Add/Remove Windows Components from Add or Remove Programs in the Control Panel.
Microsoft IIS website: http://www.microsoft.com/iis
Sun Java System Web Server
Based on the Sun One Web Server, the Sun Java System Web Server is designed for medium to large business applications. Sun Java System Web Server is available for most operating systems.Sun Java System Web Server website: http://www.sun.com/software/products/web_srvr/home_web_srvr.xml
0 comments:
Post a Comment