Thursday, December 18, 2008

HTTP 681


Documents to read:
Read the manual with a browser, such as

$ lynx /usr/share/doc/apache/manual/

Square brackets are used to separate keywords, such as filenames,
programs names etc etc from lines of text. They have no other meaning.

World Wide Web (WWW) or Web is composed of very large set of Web pages
or documents. A Web page can contain text, data and selectable links
to other Web pages. If a Web page contains items other than text, HTML
( HyperText Markup Language ) is used to represent the page.

Each Web page can be located by a unique identifier called Uniform
Resource Locator(URL).

A Web server makes a set of Web pages available to client programs.
Apache is one such Web server.

A Web browser ( client ) is the application program used to display a
Web page from a Web server. A Web browser uses a URL to access a
particular Web page. A Web browser can contact the Web server directly
or via intermediate machine called a proxy server.

HyperText Transfer Protocol(HTTP) is used for communication between a
Web server and Web browser. Web server accept connection on TCP port
80.


Create a directory [apache] under your home directory
$ mkdir $HOME/apache
$ cd $HOME/apache

Copy the following packages in [apache] directory.

libexpat1_1.95.2-6_i386.deb
apache-common_1.3.26-0woody5_i386.deb
apache_1.3.26-0woody5_i386.deb
apache-doc_1.3.26-0woody5_all.deb


Find out [apache] related installed software
$ dpkg -l | grep apache


If any [apache] is running, stop it
# /etc/init.d/apache stop

Remove the packages ( if installed )


# dpkg --purge apache
# dpkg --purge apache-common



Install the packages

# dpkg -i libexpat1_1.95.2-6_i386.deb
# dpkg -i apache-common_1.3.26-0woody5_i386.deb
# dpkg -i apache_1.3.26-0woody5_i386.deb
# dpkg -i apache-doc_1.3.26-0woody5_all.deb

$ ps ax

If the Web server is running in your host without error, connect to it
with a browser.
$ lynx http://127.0.0.1

This is the default start page of your server. You have to replace
this page with a new page, specific to your server. This page contains
some useful information about the present configuration of the server.

The page might contain the following:

Location of configuration files -----> /etc/apache
Location of DocumentRoot(Web-site) --> /var/www
Location of [cgi-bin] directory -----> /usr/lib/cgi-bin
Location of log files ---------------> /var/log/apache
Default directory index -------------> index.html


Examine the configuration files under [/etc/apache]
$ ls -l /etc/apache/

When [ httpd ] starts three configuration files are processed in the
following order [ httpd.conf, srm.conf and access.conf ].

In this experiment [srm.conf] and [access.conf] are not to be used.
Two directives

ResourceConfig /dev/null
AccessConfig /dev/null

are used to disable the files [srm.conf] and [access.conf].

Examine the default configuration file [ /etc/apache/httpd.conf ] for
the following directives, among a large number of directives.


# The httpd server runs always
ServerType standalone

# Uses standard HTTP port. See /etc/services
Port 80

# Inactivity timer
Timeout 300

# Use your-login-name as Web-master
ServerAdmin your-login-name@host.domain


Save the configuration file.


Stop [httpd]
# /etc/init.d/apache stop

Clear [httpd] log
# cat /dev/null > /var/log/apache/error.log

Start [httpd]
# /etc/init.d/apache start

Check log for errors, if any
# tail -10 /var/log/apache/error.log


Save the starting page of the [httpd]
$ cp /var/www/index.html ./index.html-$USER

Edit the starting Web page
# nano /var/www/index.html

----------------- /var/www/index.html -------------------


EIE LABORATORY CLASS - 28th March 2006



Thank you for testing my Apache Web Server... Sumit




Please visit

my home page



I am working in the laboratory with my

friends





Password file of my host





this produces error





---------------------------------------------------------

Replace "Sumit" with your name and change the date. The above file
contains two links.

The first link is to a user directory in this host.

/~sumit/xxx.html

Replace "sumit" with your login-name.

The second link is to a file in this Web-site

/my-friends.html


Test the start page
$ lynx http://127.0.0.1

Do not follow the links now as the related files are not yet in place.


Create and edit file [/var/www/my-friends.html]

-- /var/www/my-friends.html --



Sujoy Basu




Arindam Neogi




Rekha Sen



-----


Go-back



------------------------------

This file has four links. First three links are to three HTTP servers
in your laboratory. The fourth link is to the start page of your Web
server.

Test the start page and the [friends] link.
$ lynx http://127.0.0.1



Create a directory [ public_html ] in your home directory.
$ mkdir $HOME/public_html

Create and edit file [xxx.html] under [ public_html ] directory.
$ nano $HOME/public_html/xxx.html
------------------------------ xxx.html ------------------------------


Sumit's Home Page



Name: Sumit Kumar Sarkar

Roll no: eie12345

Room No: H3/234


Project:


Building a 20 watt RF Amplifier at 14 Mhz. Using two IRF530 MOSFETs

in push-pull in the final stage.




One IRF510 MOSFET ( single ended ) is used as driver.

Transmission line transformer ( 16:1 ) is used for interstage

coupling.




go back



----------------------------------------------------------------------

Test the start page and the link to your home page
$ lynx http://127.0.0.1


Two programs are to be kept under [/usr/lib/cgi-bin] directory.

-- /usr/lib/cgi-bin/sh.sumit --
#!/bin/bash
echo "Content-type: text/html"
echo
echo
/bin/cat /etc/passwd
-------------------------------
This program is correct.

The permission of the above shell script is to be modified
# chmod 0755 /usr/lib/cgi-bin/sh.sumit


The next program is wrong.

---- /usr/lib/cgi-bin/sh.wrong ----
#!/bin/bash
echo "Content-type: text/html\n\n"

/bin/cat /etc/passwd
-----------------------------------

The permission of the above shell script is to be modified
# chmod 0755 /usr/lib/cgi-bin/sh.wrong

Test the two CGI programs
$ lynx http://127.0.0.1


When the wrong CGI program is tried to be run, error occurs. The
client gets the email address of the web-master to report the error.

Request your friends to test your Web server.


For a very simple Apache web server a simple configuration file can be
used. CGI programs cannot be run with this configuration file.
----------------- /etc/apache/httpd.conf -------------------
ResourceConfig /dev/null
AccessConfig /dev/null
ServerType standalone
Port 80
ServerAdmin sumit@cc-146.cc.cemk.ac.in
ServerRoot /etc/apache
DocumentRoot /var/www
Timeout 300

LoadModule dir_module /usr/lib/apache/1.3/mod_dir.so
LoadModule mime_module /usr/lib/apache/1.3/mod_mime.so
LoadModule userdir_module /usr/lib/apache/1.3/mod_userdir.so
------------------------------------------------------------


Restart [httpd]
# /etc/init.d/apache restart

Test your server with this configuration file
$ lynx http://127.0.0.1