What Are Web Servers & How Does Web Hosting Work?

The Internet runs on what we call the 'client/server' architecture. A website sits on a web 'server' (a powerful, specially configured computer,) and is viewed through a software 'client' - which is usually a web browser such as Chrome, Firefox or Internet Explorer (see our previous post about Web Browsers).

The term 'Web Server' can actually refer both to the physical computer, and also to the software application that delivers the content. The most prominent web server platforms worldwide are 'Apache' and 'Microsoft IIS' which command 20% and 40% of the market share respectively, with nginx building its following at 18% (according to the August 2018 Netcraft Survey).

Web Hosting

Apache offers Linux-based web hosting using what we call the LAMP stack (Linux, Apache, MySQL, PHP,) which are the main components needed to build an effective web server. Microsoft IIS offers ASP hosting. Nginx (pronounced as Engine X) offers the LEMP stack - essentially the same components as the LAMP stack.

For most people or businesses new to the internet, Apache hosting is the wise choice as it’s cheaper, and has the benefit of utilising PHP and MySQL, which are open-source and free.

Web hosting can usually be purchased in a variety of formats. 'Shared Hosting' is where most people will start. This simply means that you share a web server with lots of other users and websites. It's the cheapest way of getting on-line - and does the job fine while your sites are still growing.

Next, you might look at VPS (Virtual Private Servers), which means you share with other VPS users, but you normally get your own dedicated memory and processor. This guarantees you more available power and gives you more flexibility on what you can do.

The next step is to move to a full dedicated server. This means you have complete control over an entire web server. You can configure it how you want it, and run as many sites from it as you wish. The web server itself will be located in a data-centre somewhere, preferably in the country where you expect most traffic from.

Cloud hosting also provides an advanced alternative to VPS and dedicated hosting, and is often used where you expect the load on your web server to have big spikes. One of it's main attractions is its ability to scale-up resources as required by traffic demands.

File Organisation & Rules

On an apache web server, the files that can be 'seen' via the internet are normally stored in what's called the 'public_html' directory. Generally, everything that's in this web directory, or in a subdirectory below it, is viewable via the HTTP protocol (obviously there are security and access protocols available to control this). But if it is not underneath the public_html directory branch, then it will not be available to the HTTP protocol for displaying on the web. This is actually quite useful in some situations, as you may want to place some private information, which is available to your server-side programs, in a different directory - so that it cannot be viewed across the internet.

Generally it's wise if you have a small site to store the main web pages directly in this public_html directory. If you have a larger site then you may wish to consider dividing it up into smaller sections in different subdirectories. A separate directory should always be used for images and graphics however, and it's good practice to also keep java scripts, flash and multimedia elements in their own directories also.

You should also stick to one single standard naming convention so that everything is consistent. Remember that capital letters on many servers such as Apache are different to lowercase letters. So "design.htm" is different to "Design.htm". This can cause no end of difficult-to-find problems, but is normally avoided by using a web development environment such as Dreamweaver - as it will help manage internal linking.

You also want to avoid using any spaces in filenames - use an underscore or hypen. And nearly all special characters, such as:

/ \ ? % * : “ | < > .

...are not allowed either - as they're reserved for Operating System (OS) use.

Web File Types

Files on the web are stored in a variety of formats - each with its own file extension. Web files can comprise of data, text, graphics, audio and video. Basic web pages are essentially text files - and have an extension of.html or.htm.

.htm or.html - standard web pages (HTML)

.jpg, .gif, .png - image files

.pdf - Adobe Acrobat Reader files

.php, .asp, .jsp, - Server-side program-script files (which are 'parsed' at the web-server - not in the browser)

Web servers deliver web content according to the extension of the file being processed. If it's a .htm or .html file then it will be sent 'as-is' to the browser for displaying (otherwise known as 'rendering'.) If it's a .php or an .asp file on the other hand, then the web server will pre-process that file and only send the outputs delivered by that script. This is how PHP and ASP deliver dynamic and changing content to your web-browser.

JavaScript is code that is delivered in-line with the HTML, and is executed by the web-browser. This allows for dynamic effects and data processing locally. AJAX allows for JavaScript to communicate with a web-server, without undergoing a page-refresh (which would essentially be required for an .asp or .php page to re-parse itself). Combinations of these languages allows for a variety of useful on-page processing to happen.

Browsers will not recognise or correctly display files that are not saved with the correct file extension. The file extension lets the browser know how to handle the file or what plug-in is required. For example, if you gave an HTML file a .txt extension, it would simply appear as a full txt file - as though you were editing it.

Internet Protocols

HTTP (HyperText Transfer Protocol)

This is the web standard or protocol which forms the basis of data communication for the World Wide Web. You will often see this at the start of a web address signifying that it is an online resource.

HTTP functions by submitting HTTP requests for information from a client machine (usually a web browser) to a web server. The web server then sends responses back to the client.

FTP (File Transfer Protocol)

FTP is a network protocol that is used for moving files to (and between) web servers and web hosts.

For most users, an FTP program such as 'CuteFTP', 'FireFTP' or 'FileZilla' will be used for uploading your web pages to your web server. CuteFTP is a commercial program, whereas FileZilla is open-source and free to download. FireFTP is a plugin for Mozilla Firefox so that FTP can be done from within your browser.

FileZilla can be downloaded from : http://filezilla-project.org

The FireFTP plugin can be downloaded from : http://fireftp.net