Intro to LAMP, Web Architecture, and HTTP

CS418 - Web Programming - Spring 2015

Old Dominion University

Mat Kelly (

Slides adapted from version by Dr. Michele C. Weigle


  • Linux - operating system
  • Apache - web server
  • MySQL - relational database
  • PHP - server-side scripting


  • Free and Open Source Software (FOSS)
  • Components are theoretically swappable
    • e.g., another FOSS server-side script language can be used in place of PHP
  • No restrictions on derivative software
* Camel icon a trademark of O'Reilly Media

The Web

  • User agent (client)
    • Frequently a Web Browser
    • Alternatively, a script or command-line tool (wget, curl)

The Web

  • User agent (client)
    • Frequently a Web Browser
    • Alternatively, a script or command-line tool (wget, curl)
  • Web Server (server)
    • Handles requests from clients

Web Terminology

  • Uniform Resource Identifier (URI)
    • addresses web pages
  • Web pages consist of "objects"
    • Mostly HTML pages
    • Also includes images, scripts, other objects


  • Uniform Resource Identifier (URI)
    • news:comp.infosystems.www.servers.unix
  • Uniform Resource Locator (URL)
  • Uniform Resource Name (URN)
    • Unambiguous identifier
      • defines identity (not necessarily location)
    • urn:isbn:978-0321751041

Term Definitions: RFCs

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Note that the force of these words is modified by the requirement level of the document in which they are used.

1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification.

2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the definition is an absolute prohibition of the specification.

3. SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.

5. MAY This word, or the adjective "OPTIONAL", mean that an item is truly optional. One vendor may choose to include the item because a particular marketplace requires it or because the vendor feels that it enhances the product while another vendor may omit the same item. An implementation which does not include a particular option MUST be prepared to interoperate with another implementation which does include the option, though perhaps with reduced functionality. In the same vein an implementation which does include a particular option MUST be prepared to interoperate with another implementation which does not include the option (except, of course, for the feature the option provides.)

RFC 2616 - HTTP/1.1

  • Describes Hypertext Transfer Protocol structure & dynamics
  • Extends RFC 1945 (HTTP/1.0) and RFC 2068 (HTTP/1.1, now obsolete)
  • Newer definition for the Web describes URIs, protocols, and formats

RFC 2616 Examples

§ 10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows...that an old resource is permanently unavailable and has no forwarding address
§ 10.3.2 301 Moved Permanently
The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs
§ 10.2.1 200 OK
The request has succeeded. The information returned with the response is dependent on the method used in the request
§ 10.4.6 405 Method Not Allowed
The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.

URI Schemes

  \_/   \_______________/ \_________/ \__/            \___/ \_/ \______________________/ \__/
   |           |               |       |                |    |            |                |
   |       userinfo           host    port              |    |          query          fragment
   |    \________________________________/\_____________|____|/ \__/        \__/
 scheme                 |                          |    |    |    |          |
  name              authority                      |    |    |    |          |
   |                                             path   |    |    interpretable as keys
   |                                                    |    |
   |    \_______________________________________________|____|/       \____/     \_____/
   |                         |                          |    |          |           |
 scheme              hierarchical part                  |    |    interpretable as values
  name                                                  |    |
   |            path               interpretable as filename |
   |   ___________|____________                              |
  / \ /                        \                             |
  urn:example:animal:ferret:nose               interpretable as extension

 scheme /                  \
  name  userinfo  hostname       query
  _|__   ___|__   ____|____   _____|_____
 /    \ /      \ /         \ /           \


Important Web Architecture Terms

  • URIs identify Resources
  • Representations represent Resources
  • When URIs are dereferenced, they return representations (i.e., a resource is never returned)
  • Different representations may be returned for the same URI (e.g., English vs. French version)
Web architecture

W3C Web Architecture

The tools we have to solve the interoperability problems are Resource, URI, and Representation

URI diagram

Content Negotiation Examples

  • Accept-Language: en; q=1.0, de; q=0.5
  • Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1
  • Accept-Datetime: Wednesday, 14 January 2015 15:15:00 GMT

HTTP Overview

  • HTTP uses TCP
    • Browser initiates TCP connection to server (on port 80)
  • HTTP messages exchanged between browser and web server
  • HTTP is stateless
    • server maintains no information about past browser requests

HTTP Example

  1. User enters URI
    • Referenced object contains HTML text and references images
  2. Browser sends an HTTP GET request to
  3. Server retrieves and sends the client the HTML file
  4. Browser reads the file and sequentially makes separate requests for each embedded image.

HTTP Request Message Format

  • HTTP messages are ASCII (human-readable)
$ curl -iv
  • CLIENT→Server
  • * Connected to ( port 80 (#0)
  • > GET /~mkelly/ HTTP/1.1
  • > User-Agent: curl/7.37.1
  • > Host:
  • > Accept: */*
  • < HTTP/1.1 200 OK
  • < Server: nginx
  • < Date: Wed, 14 Jan 2015 00:46:19 GMT
  • < Content-Type: text/html
  • < Transfer-Encoding: chunked
  • < Connection: keep-alive
  • < Vary: Accept-Encoding
  • <!DOCTYPE html>
  • <html>
  • <head>

HTTP Methods

    • What methods are defined on this URI?
    • Rarely supported for most URIs
  • PUT
    • Rarely supported. Equivalent to Unix $ echo "hello world" > temp.txt
  • POST
    • Frequently used for passing credentials.

More HTTP Methods!

MethodRFCSupported (Count)Percentage

from S. Alam "Support for Various HTTP Methods on the Web"