lis650 lecture 5 html forms javascript, http and apache thomas krichel 2005-02-26

82
LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Upload: roderick-walsh

Post on 14-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

LIS650 lecture 5html forms

javascript, http and apache

Thomas Krichel

2005-02-26

Page 2: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

today

• forms filling in to prepare for active web sites• javascript• http• apache introduction

Page 3: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Forms• Forms are parts of an HTML document that a

user can fill in. • The thing that users act on are called the controls

of the form. They include buttons, checkboxes, text areas, file selections...

• some controls are hidden• elements used in forms use a special attribute

group that I will call the "form attributes". I will discuss them now.

• Let us look first at an example to fix ideas.

Page 4: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

form attribute: "tabindex"

• Stupid users use the mouse to fill in form. Smart users use the tab character on the keyboard. It is much quicker.

• if you set the "tabindex" on a in input, you can set the order. The value of the attribute is a number between 0 and 32767. The input with a lower number will be dealt with before the one with a higher number.

Page 5: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

form attribute: "readonly"

• If you set readonly="1" the control can only be read but not set. readonly="0" is the default, it means that the control can be set.

• if an input is readonly="1"– it can receive focus but cannot be modified by the user.– it is included in tabbing navigation.– it is transmitted to the server for processing

Page 6: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

form attribute: "disabled"

• If you set disabled="1" the control can only be read but not set. disabled="0" is the default, it means that the control can be set.

• if an input is disabled="1"– it can not receive focus and can not be modified– it is excluded in tabbing– it is not transmitted to the server for processing.

Page 7: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

<form>

• This element encloses a form. • It accepts the core and i18n attributes.• It admits an "action" attribute. Its value is the URL

of a script that will handle the form after it is submitted.

• It admits a "method" attribute. This attribute determines how the form is submitted to the script. There are only two choices – get– post

Page 8: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

The GET method

• if you use get, the form data is transmitted by appending it to the URL of the script.

• Google do it that way• Advantage: you can bookmark the form.• Problem: there is a limit of 1024 chars for the

URL, therefore only a limited information can be transmitted in this way.

Page 9: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the POST method

• if you use post, the user agent sends the form as a POST message to the server.

• The data is sent in the body of the http exchange.• Thus it can be as long as you want.• If you use POST you can set the content-type of

the message with a special attribute "enctype"

Page 10: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

more attributes to <form>

• Here are two more attributes I will list for completeness– "accept-charset" says what character sets will be

accepted by the – "accept" says what MIME-types can be accepted.

Page 11: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

<input>

• This element creates a control. Usually a form has several <input>s as well as text that explains the from.

• It admits the core, i18n and the from attributes.

Page 12: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the "type" attribute of <input>

• This attribute can only take the following values– text enter text– password enter text, but don't echo on screen– checkbox enter checks on boxes– radio check one select– submit press to submit form– reset reset form– file upload file (can only be done with PUT)– hidden hidden form data, not shown– image an image to decorate submit button– button a button

Page 13: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the "name" attribute of <input>

• This give a name to the control that the users are setting.

• Think of it like an attribute name in HTML• and what the user writes is the attribute value

Page 14: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the "size" attribute of <input>

• It lets you set the initial size of the input field.• When the type is 'text' or 'password' the value you

give to this field is the number of characters.• Otherwise it is the number of pixels.

Page 15: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the "maxlength" attribute of <input>

• this sets the maximum length on the value. • note that this is different from the size of the input

field because there is scrolling.• if you don't specify a maximum length there is no

limit.

Page 16: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the "value" attribute of <input>

• This gives the initial value of the <input>. • The initial value is shown to the user, and sh• "value" is optional but should be given for the

radio and checkbox type.

Page 17: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

other attributes of <input>

• When the input is of type "radio", setting the "checked" attribute to any value will tell the browser what button is initially set. Of course there can only be one of them.

• When the input is of type "checkbox", setting the "checked" attribute to any value will make sure it is checked initially.

• When the input is of type 'image' the "src" attributes give the URL of the image.

Page 18: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the <button> element

• This makes a button for decoration.• It takes a "type" attribute that can be either be

'button', 'submit' or 'reset'.• It has takes a "name" attribute for the name of the

control that it sets.• It takes a "value" attribute attribute to set a value.• And it can have character contents!

Page 19: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

creating menus

• This is done with <select> element. • Each <select> element can have a number of

<option> elements that contain the options that the user can choose from.

Page 20: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

attributes to <select>

• "multiple" can be set to 'multiple' to allow or disallow multiple selections.

• "size" sets how many rows of the selection should be displayed at any one time.

• "name" has the name of the control that is set.• It also takes the core and i18n attributes.

Page 21: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

attributes to <option>

• "value" can be used to set the value of the control when the value set is different than the contents string of the option element.

• "label" can be set to label the option. if it is set, the user agent should use label rather than the content. At least this is what the spec says. Firefox does not seem to agree.

• <option> takes the core and i18n attributes.

Page 22: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

<optgroup>

• This element has <option> elements as its children.

• It is used to create hierarchical options. This is mainly a time and space-saving device in the presence of many options. Say

• <optgroup label="Winter"><option label="January"/><option label= "February"/><option label="March"></optgroup>

• <optgroup> takes the same attributes as <option>.

Page 23: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the <textarea> element

• This creates a text area where you can put a large chunk of text.

• "name" sets the name of the control that is set.• "cols" sets the number of columns in the text

area.• "rows" sets the number of rows in the text area. • <textarea> also admits the i18n, core and form

attributes.

Page 24: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

<label>

• This is a way to add labels for inputs. • Normally, the input label should be taken from the

"label" attribute of the input.• <label> can be used if the other method can not

be. • It accepts a "for" attribute to give the input for

which it is the label is for. Example:• <input name="sex"/><label for="sex">sex</label>

Page 25: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

summary

• forms deliver data to the server. The server can then process the data and deliver a response.

• Active effects can also be done client-side. This is done using the <script> element that mostly uses a language called javascript.

Page 26: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

the <script>

• <script> is an element that calls a script.• It requires a "type" attribute that gives the type of

the script language. e.g. type="text/javascript".• It takes the "src" argument that gives a URI where

the script can be found. Such a script is called an external script.

• It takes a "defer" attribute. If set as defer="1" you tell the user agent that the script will generate no output. This helps the user agent in that case.

Page 27: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

example

<script type="text/javascript">

document.write("hello, world");

</script>• Interestingly enough, you can place this script in

the head or the body. • This is an example of an automated script. The

user has to do nothing to get the script to run.• You can also trigger a script. To do that, we have

to study some more HTML attributes. We will do that later.

Page 28: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

external script

• You can also create an external file, say hello.js with the line

document.write("hello, world");• Then you can call it up in the html file

<script type="text/javascript" src="hello.js"/>

Page 29: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

default script language

• You should set the default scripting language used in the document using the <meta> element in the <head>

• <meta http-equiv="content-script-type" content="text/javascript"/>

• If you don't the validator does not complain, but I don't see other ways to specify the language.

Page 30: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Javascript history

• A programming language that was developed by Netscape for their browser in 1995.

• To counter, Mickeysoft developed Jscript.• It has been standardized by the European

Computer Manufacturers Association as ECMA 262.

Page 31: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

principal features

• It contains instructions for a user agent to execute. Javascript is not run by the server.

• It resembles Java, but not the same language.• It is an object-oriented language.

Page 32: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

object

• In an object-oriented language, an object is the prime focus of attention.

• An object has properties and methods.• Example from real life. Let a bus be an object.

– “color” of the bus is a property– “move to next station” is a method

Page 33: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

objects in javascript

• Properties are accessed by

object_name.property_name• Methods are accessed by

object_name.method_name()• where object_name is the name of an object,

property_name is the name of a property and method_name() is the name of an object. Note the use of the dot and the parenthesis.

Page 34: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Example• Syntax rules

– Comments are started with // and go to the end of the line.

– Instructions are terminated with semicolon

• Example// create a new object called busnew bus = Object();// paint it white --- set a propertybus.color = ‘white’;// move to next stop --- apply a methodbus.movetonextstop();

Page 35: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

event attributes• Event attributes can be given to elements (like

any attribute, really)• The name of the attributes gives a certain event

that could happen to the element.• The value of the event attribute is the script to be

executed when the event occurs on the element that has the event attribute.

• Example

<p onmouseover="stink">Cow shit is ... </p>

as the user moves the mouse over the paragraph, the browser fires up an imaginary script called stink that makes it start to stink.

Page 36: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

core event attributes I

• "onclick" occurs when the pointing device button is clicked over an element.

• "ondblclick" occurs when the pointing device button is double clicked over an element.

• "onmousedown" occurs when the pointing device button is pressed over an element.

• "onmouseup" occurs when the pointing device button is released over an element.

• "onmouseover" occurs when the pointing device is moved onto an element.

Page 37: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

core events attributes II

• "onmousemove" occurs when the pointing device is moved while it is over an element.

• "onmouseout" occurs when the pointing device is moved away from an element.

• "onkeypress" occurs when a key is pressed and released over an element.

• "onkeydown" occurs when a key is pressed down over an element.

• "onkeyup" occurs when a key is released over an element.

Page 38: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

special event attributes

• "onfocus" occurs when an element receives focus either by the pointing device or by tabbing navigation. This attribute may only be used with the <a> element, and some form elements that we have not covered.

• "onblur" occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus.

Page 39: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

more special event attributes

• "onsubmit" occurs when a form is submitted. It only applies to the <form> element.

• "onreset" occurs when a form is reset. It only applies to the <form> element.

• some more are only used with other form elements...

• Let us look at some examples

Page 40: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

two stupid examples

<html><head><title>javascript test</title>

<meta http-equiv="content-script-type" content="text/javascript"/></head>

<body><p onmouseover="alert('Today is '+Date());" >time</p><hr/>

<p onmouseover=

"document.write('not funny')">joke</p> <p></body></html>

Page 41: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

An even more silly example

<html><head><title>Bush in the bush</title>

<meta http-equiv="content-script-type" content= "text/javascript"/><script type="text/javascript">

prbu=new Image(); prbu.src="bush.jpg";

natb=new Image(); natb.src="natgeo.jpg"; </script></head><body><h4>Bush in the bush</h4><div><img id="bush" src="bush.jpg" onmouseover="document.bush.src=natb.src"

onmouseout="document.bush.src=prbu.src" alt="bush in the bush"/></div></body></html>

Page 42: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

http

• Stands for the hypertext transfer protocol. This is the most important application layer protocol on the Internet today, because it provides the foundation for the world wide web.

• defined in Fielding, Roy T., James Gettys, Jeffrey C. Mogul, Paul J. Leach, Tim Berners-Lee ``Hypertext Transfer Protocol -- HTTP/1.1'' (1999), RFC 2616

Page 43: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

history

• 1990: version 0.9 allows for transfer of raw data.• 1996: rfc1945 defines version 1.0. by adding

attribute:value headers.• 1999: rfc 2616

– adds support for

• hierarchical proxies• caching, • virtual hosts and some• Support for persistent connections

– is more stringent.

Page 44: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

http resource identification

• identification of resources is assumed through Uniform Resource Identifiers (URI).

• As far as http is concerned, URIs are string.

• http can use ``absolute'' and ``relative'' URIs.

• A URL is a special case of a URI.

Page 45: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

rfc about http

An application-level protocol for distributed, collaborative, hypermedia information systems.

HTTP is also used as a generic protocol for communication between user agents and proxies/gateways to other Internet systems, including those supported by the SMTP, NNTP, FTP, Gopher, and WAIS protocols. In this way, HTTP allows basic hypermedia access to resources available from diverse applications.

Page 46: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

http assumes transport

• http assumes that there is a reliable way to transport data from one host on the Internet to another one.

• All http requests and responses are separate TCP connections. The default is TCP port 80, but other ports can be used.

Page 47: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

use of other standards

• http shares the same registry as the MIME multimedia email extensions. It is based at the IANA, at

http://www.isi.edu/innotes/iana/

assignments/media-types/media-types

• The default character set is ISO-8859-1.

Page 48: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Absolute http URL

• the absolute http URL is

http://host[:port][[abs_path][?query]]

• If abs_path is empty, it is /.

• The scheme name "http" and the host name are case-insensitive.

• Characters other than those in the ``reserved'' and ``unsafe'' sets of RFC 2396 are equivalent to their ``%HEX HEX'' encoding.

• optional components are in [ ]

Page 49: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

http messages• There are two types of messages.

– Requests are sent form the client to the server.

– Responses are sent from the server to the client.

• The generic format is the same as for email messages:– start line

– message headers

– empty line

– body

• Empty lines before the start line are ignored.

• The request's start line is called the request-line.

• The response start line is called the status-line.

Page 50: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

overall operation server side

• Server sends response, required items are– status line– protocol version– success or error code

• optional items are– server information– body

Page 51: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

overall operation: client side

Client sends request, required items are– method– request URI– protocol version

• optional items are– request modifiers– client information

• Let us now look at different methods

Page 52: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

GET and HEAD method

• The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process.

• The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.

Page 53: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Conditional & partial GET• The semantics of the GET method change to a

``conditional GET'' if the request message includes an– If-Modified-Since– If-Unmodified-Since– If-Match– If-None-Match– If-Range header

• The semantics of the GET method change to a ``partial GET'' if the request message includes a Range header field. A partial GET requests that only part of the entity be transferred

Page 54: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

The POST method• The POST method is used to request that the

origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:– Annotation of existing resources;– Posting a message to a bulletin board, newsgroup,

mailing list, or similar group of articles;– Providing a block of data, such as the result of

submitting a form, to a data-handling process;– Extending a database through an append operation.

Page 55: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

PUT and DELETE methods

• The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity should be considered as a modified version of the one residing on the origin server.

• The DELETE method requests that the origin server delete the resource identified by the Request-URI.

Page 56: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

The request headers• Accept: Accept-Charset:• Accept-Encoding: Accept-Language:• Authorization: Expect:• From: Host: • If-Match: If-Modified-Since:• If-None-Match: If-Range:• If-Unmodified-Since: Max-Forwards:• Proxy-Authorization: Range:• Referer: TE:• User-Agent:

Page 57: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

The status line

• The status line is a set of lines that are of the form

• HTTP-Version Status-Code Reason-Phrase• The status code is a 3-digit number used by the

computer.• The reason line is a friendly note for a human to

read.

Page 58: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Status code classes

• 1 Informational: Request received, continuing process

• 2 Success: The action was successfully received, understood, and accepted

• 3 Redirection: Further action must be taken in order to complete the request

• 4 Client Error: The request contains bad syntax or cannot be understood

• 5 Server error: The request is valid but can not be executed by the server

Page 59: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Error codes• 100 Continue • 101 Switching Protocols • 200 OK • 201 Created • 202 Accepted • 203 Non-Authoritative Information • 204 No Content • 205 Reset Content • 206 Partial Content

Page 60: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Error codes II

• 300 Multiple Choices • 301 Moved Permanently • 302 Found • 303 See Other • 304 Not Modified • 305 Use Proxy • 307 Temporary Redirect

Page 61: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Error codes III

• 400 Bad Request • 401 Unauthorized • 402 Payment Required • 403 Forbidden • 404 Not Found• 405 Method Not Allowed• 406 Not Acceptable• 407 Proxy Authentication Required• 408 Request Time-out

Page 62: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Error codes IV

• 409 Conflict• 410 Gone• 411 Length Required• 412 Precondition Failed• 413 Request Entity Too Large• 414 Request-URI Too Large• 415 Unsupported Media Type• 416 Requested range not satisfiable• 417 Expectation failed

Page 63: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Error codes V

• 500 Internal Server Error• 501 Not Implemented• 502 Bad Gateway• 503 Service Unavailable• 504 Gateway Time-out• 505 HTTP Version not supported

Page 64: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Response headers• Accept-Ranges:

• Age:

• Etag:

• Location:

• Proxy-Authenticate:

• Retry-After:

• Server:

• Vary:

• WWW-Authenticate:

Page 65: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Entity headers, common to response and request

• Allow:• Content-Encoding:• Content-Language:• Content-Length:• Content-Location:• Content-MD5:• Content-Range:• Content-Type:• Expires:• Last-Modified

Page 66: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

The body

• The entity-body (if any) sent with an HTTP request or response is in a format and encoding defined by the entity-header fields.

• When an entity-body is included with a message, the data type of that body is determined via the header fields Content-Type and Content-Encoding

Page 67: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

example status: redirect

• If you use Apache, you can create a file .htaccess (note the dot!) with a line

redirect 301 old_url new_url• old_url must be a relative path from the top of

your site• new_url can be any URL, even outside your site • This works on wotan by virtue of configuration

set for apache for your home directory. Examples– redirect 301 /~krichel http://openlib.org/home/krichel– redirect 301 Cantcook.jpg http://www.foodtv.com

Page 68: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Apache

• Is a free, open-source web server that is produced by the Apache Software Foundation, see http://www.apache.org

• It has over 50% of the market share.

• It runs best on UN*X systems but can run an a Mickeysoft OS as well.

• I will cover it here because it is freely available.

• Wotan runs version 2.

Page 69: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Apache in debian

• /etc/apache2/apache.conf is set main configuration file.

• /etc/init.d/apache2 action, where action is one of– start– stop– restart

is used to fire the daemon up or down.• The daemon runs user www-data

Page 70: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Virtual host

• On a single installation of Apache several web servers can be supported.

• That means the server can behave in a different way according to how it is being addressed.

• The easiest way to implement addressing a server in different was is through DNS host names.

Page 71: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Directives in apache.conf

• This file contains directives that control the operation of the Apache server process as a whole (the 'global environment').

• Some of them are

– the server root, where it finds its configuration

– the time out for requests

– which port to listen

• another part of apache.conf has extensive settings to deal with content

– different languages

– different character sets

– different MIME types

Page 72: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Modules

• To extend Apache, modules have written. The modules are kept in a directory modules-available

• Modules that are enabled are listed in the directory modules-enabled.

• Looking at this gives you vital information about what the server can do.

Page 73: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Server directives• User

– Gives the user name apache runs under

• Group– Gives the group name the server runs under

• ServerAdmin– Email of a human who runs the default server

• ServerName– The name of the default server

• DocumentRoot– The top level directory of the default server

Page 74: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Directory options

• Many options for a directory can be set with• <directory name> instructions<directory>• Name is the name of a directory.• Instructions can be a whole lot of stuff

Page 75: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Directory instructions

• Options sets global options for the directory, it can be – None– All– Or any of

• Indexes (form directory indexes?)• Includes (all server side includes?)• FollowSymlinks (allow to follow server-side includes)• ExecCGI (allow cgi-scripts?)• MultiViews

Page 76: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Access control

• Can be part of <directory> to set directory level access control

• Example– Allow from friendly.com– Deny from evil.com

• Sometimes you have to set the order, example– Order allow, deny

Page 77: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Authentication

• This is used to enable password access. In that case the authentication is handled by a file .htaccess in the directory.

• The AllowOverride instruction is used to state what the user can do within the .htaccess file. Depending on its values, you can password protect a web site.

• We will not discuss this further here.

Page 78: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Userdir

• This sets the directory that is created by the user in her home directory to be accessed by requests to ~user.

• On wotan, we have• UserDir public_html• That is the default, actually.

Page 79: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Set up permission for user home directories

<Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Options +Includes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <Limit GET POST OPTIONS PROPFIND> Order allow,deny Allow from all </Limit> <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE

LOCK UNLOCK> Order deny,allow Deny from all </Limit></Directory>

Page 80: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Logs

• The web server logs every transaction.• The are severeal types of logs that used to be

kept separately, in early days. • 209.73.164.50 - - [26/Jan/2003:09:19:51 -0500]

"GET /~ramon/videos/ntsc175.html

HTTP/1.1" 206 808• Additional information may be kept in the referer

and user agent log. • The referer log may have some interesting

information on who links to your pages.

Page 81: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

Virtual hosts

• Most apache directive can be wrapped in a <virtualhost> </virtualhost> grouping.

• This implies that the only hold for the virtual host. Example, from wotan

<VirtualHost *>

ServerAdmin [email protected]

DocumentRoot /home/connect/public_html

ServerName connections2003.liu.edu

ErrorLog /var/log/apache/connections2003-error.log

CustomLog /var/log/apache/connectios2003-access.log common

</VirtualHost>

Page 82: LIS650 lecture 5 html forms javascript, http and apache Thomas Krichel 2005-02-26

http://openlib.org/home/krichel

Thank you for your attention!