Web Servers and Services
What is a Web site? Quite simply, a Web site is a collection of files on a hard drive of a Web server. A domain name supplies two things: the logical name of the site, and the address of the server where the files are located.
What is a Web Server? A Web server is just a computer (often running Linux) with a lot of hard drive space and a fast Internet connection. It maintains a mapping between domain names and the actual files on its hard drives, and it serves up those files when requested by a Web browser (or other programs). Web servers run several special programs that allow them to serve as Web servers:
- HTTP Server: this is the actual program that serves up HTML pages on request. The most commonly-used Web server is Apache. Requests in the HTTP protocol typically use port 80.
- FTP Server: this program supports the FTP file-transfer protocol, allowing people with permission to manipulate files directly on the server. This is what Web developers use to copy files back and forth from their development machines to Web servers.
- MySQL: this open-source database server is widely used on the Web.
- PHP: this open-source language is suppoorted by virtually all Web servers, providing a programming interface to the backend services. You can install PHP on your PC or Mac, but it's easier to install a package:
This diagram shows the basic styles of interactions between users and a Web server.
This diagram shows a conceptual view of how a Web browser connects to a Web server, as well as how a user can privately interact with a Web server to transfer files and access services. Above the line, a user’s Web browser interacts with any Web server on the Web using a protocol called HTTP. The browser sends requests to the Web server, and it responds with HTML pages. Notice, though, that the Web server can call on many services besides its own hard drive. These other services actually create the HTML as it is requested, rather than using static pages that change rarely.
Below the line, however, a user with the proper permissions can connect to the private side of a Web server, and directly access the Web server’s hard drive and other services (such as MySQL databases).
Recommended Directory Structure for Web Sites
- Web site files are typically placed in a hierarchical directory structure. The top of that hierarchy, called the root directory, contains the “home page” of the site—the default page that is returned when you request the site by domain name only, without specifying an actual HTML page.
- When a user requests a Web page only by the domain name, the Web server must decide which HTML page should be returned. The server looks for either index.html or default.html, and returns the first one it finds. If PHP is in use, the Web server may also look for index.php and default.php if the HTML files were not located in the root directory.
- It is a good practice to cluster similar things in subdirectories under the site’s root. At the least, you should consider creating a CSS subfolder to hold CSS and Javascript files, and an images subfolder to hold the images used on your site. By moving these files below the root folder, you can get at your HTML files more quickly and cleanly.
Local vs Remote
The typical model of working with a Web site is to have the Master site files on your hard drive, and then place a copy of the Master site on a Web server (another computer). Using manual (FTP) or automated (Dreamweaver) means, you can then synchronize the master site with the copy of the site on your Web server. When testing your site, you can either test directly from your hard drive, or you can upload the files to your Web server for testing. If you don’t use any server-side technologies like PHP, then reading the HTML from your hard drive is exactly like reading the HTML from the Web server.
The key thing to remember to avoid overwriting your files: Left = Local • Right = Remote!
