How Does an Internet Server Work?
-
Components of a Server
-
A server is a computer that stores websites on its hard drive. It includes the actual server software, which allows other computers to request web pages from it; various "server-side" languages, such as PHP, which add functionality; a program that hosts databases, such as MySQL; and often email server software.
Sending Requests
-
Every computer that's connected to the Internet is assigned an Internet Protocol (IP) Address, which is a series of numbers. To make those numbers more human-friendly, the Domain Name System (DNS) exists, which assigns domain names (such as Google.com) to a particular IP address (such as 66.102.9.104). Whenever an Internet user types an address into a browser's address bar, the DNS looks up the IP address associated with the domain name and then finds the server associated with the IP. The server then receives the request.
-
Processing the Request
-
All web pages will be sent eventually back to the client (the Internet user or the user's computer) in simple hypertext markup language (HTML) format. When the request is for a simple HTML page, the server simply sends that page back. Often, however, the request is more complicated; for example, when the client fills out a contact form or tries to upload an article to a blog.
PHP
-
PHP is a programming language that exists on the server that, among other things, can process the results of forms a client completes. Let's say a client is trying to send a webmaster a message using a built-in contact form on a web page. The page, written in HTML, can create forms, but it can't really do anything with them. To actually process them, the server uses a PHP file that the HTML file points to. The information on the form is then stored by the PHP file in a set of variables (signified in PHP by a $ symbol) that can be used for whatever purpose is needed. In this case, the message intended for the webmaster could be stored in a variable called "$message," which the PHP file could then send to the webmaster's email address.
SQL
-
Websites are really all about data. SQL is a language that can create and maintain databases, and MySQL is a popular server-side program for housing and manipulating those databases. To use a popular example, when you write a post for a blogging service such as WordPress, WordPress stores the content of that post inside a giant database filled with all your posts. When you click "Publish," you're really just filling out a form that gets processed by PHP in the same manner as the above example. The only difference is PHP then sticks the information inside a MySQL database on the server. When someone requests the page that holds the post, your post is pulled from the database by PHP and then outputted to HTML--which is the only thing the viewer sees, because the database and the PHP program only exist on the server.
Sending Information Back
-
The server sends back the resulting HTML web page via the web's main "transfer protocol" called the HyperText Transfer Protocol. That's the "http" at the beginning of every web address.
-