Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit-01: Introduction To WEB

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Web Programming (WP)

GTU # 3160713

Unit-01
Introduction to
WEB

Prof. Vijay M. Shekhat


Computer Engineering Department
Darshan Institute of Engineering & Technology,
Rajkot
vijay.shekhat@darshan.ac.in
9558045778
✓ Outline
Looping

✔ Introduction to WEB
✔ What is Internet?
✔ What is WWW?
✔ How the WEB works?
✔ HTTP Protocol
✔ Client Server architecture
✔ Web Servers
✔ Installing Web Server
✔ Configuring Web Server
What is Internet?
The Internet is a massive network of networks, a networking infrastructure.
It connects millions of computers together globally, forming a network in which any
computer can communicate with any other computer as long as they are both connected to the
Internet.
Information that travels over the Internet uses many different set of rules which are known
as protocols.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 3


What is WWW?
WWW stands for World Wide Web.
A technical definition of the WWW is − All the resources and users on the Internet that are
using HTTP.
HTTP stands for Hypertext Transfer Protocol which is a text-based request-response
protocol.
HTTP is an application layer protocol that allows web-based applications to communicate
and exchange the data.
HTTP is a TCP/IP based protocol.
After making the request, the client disconnects from the server, then when the response is
ready the server re-establish the connection again and deliver the response, so it is a
connectionless and stateless protocol.
HTTP is the protocol being used to transfer hypertext documents that makes the World Wide
Web possible.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 4


How the Web Works?
World Wide Web (WWW) use classical client / server architecture.

Server running Web


Client running a HTTP
Server Software
Web Browser (Apache, IIS,
Page request
Tomcat, etc.)

HTTP
Server response

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 5


HTTP request
The HTTP request message consist of following,
A request line (e.g. GET /index.php HTTP1.1)
Request header fields (e.g. Accept-Language: en)
An empty line (CRLF)
An optional message body
The request line and other header fields must end with CRLF (Carriage return, Line Feed)
(/r/n)
A request line contains the method of request followed by the resource we want and at the
end protocol version used.
HTTP Request Methods: GET, POST, PUT, DELETE etc...
There are many request header fields available with HTTP Request, some of are listed
below
Accept : Media type(s) that is/are acceptable for the response. (e.g. Accept: text/html)
Accept-Charset: Character sets that are acceptable. (e.g. Accept-Charset: utf-8)
Date: The date and time at which the message was originated (e.g. Date: Tue, 15 Nov 1994 08:12:31
GMT)
Host:
Prof. The
Arjun V. Bala domain name of the server (e.g.
#3160713 ⬥ Unitdarshan.ac.in)
(WP)Host: 01 – Introduction to WEB 6
HTTP Request (Example)

GET /index.php HTTP/1.1 index.php is requested from server using GET


method of HTTP version 1.1

User-Agent: Mozilla/5.0 (Windows NT Version 5.0 of mozila browser is used on windows


10.0; Win64; x64) AppleWebKit/537.36 10 (64 bit) while requesting the page from the
(KHTML, like Gecko) server.
Chrome/88.0.4324.150 Safari/537.36

Host: www.darshan.ac.in Host of the requested page is www.darshan.ac.in

Accept-Language: en-us Client accepts US English locale while receiving


the response from the server.

Accept: text/html Client accepts text file containing the HTML in it


while receiving the response from the server.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 7


HTTP Response
After receiving and interpreting a HTTP request message, a server responds with an HTTP
response message.
The HTTP response message consist of following,
Status-Line (format= HTTP-Version SP Status-Code SP Reason-Phrase CRLF)
*(( general-header | response-header | entity-header ) CRLF)
An empty line (CRLF)
An optional message body
Status-Line consist of
HTTP-Version, which can be HTTP/1.1
Status-Code is a 3 digit code which is in below format
▪ 1xx: Informational - Request received, continuing process
▪ 2xx: Success - The action was successfully received, understood, and accepted
▪ 3xx: Redirection - Further action must be taken in order to complete the request
▪ 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
▪ 5xx: Server Error - The server failed to fulfill an apparently valid request
Reason-Phase is a textual representation of the status code in human readable format.
Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 8
HTTP Status Codes with reason phrase
"100": Continue "404": Not Found
"101": Switching Protocols "405": Method Not Allowed
"200": OK "406": Not Acceptable
"201": Created "407": Proxy Authentication
Required
"202": Accepted
"408": Request Time-out
"203": Non-Authoritative Information
"409": Conflict
"204": No Content
"410": Gone
"205": Reset Content
"411": Length Required
"206": Partial Content
"412": Precondition Failed
"300": Multiple Choices
"413": Request Entity Too Large
"301": Moved Permanently
"414": Request-URI Too Large
"302": Found
"415": Unsupported Media Type
"303": See Other
"416": Requested range not
"304": Not Modified satisfiable
"305": Use Proxy "417": Expectation Failed
"307": Temporary Redirect "500": Internal Server Error
"400": Bad Request "501": Not Implemented
"401": Unauthorized "502": Bad Gateway
Refer:
"402": Payment Required "503": Service Unavailable https://www.w3.org/Protocols/rfc2616/rfc2616-sec
6.html for more details on HTTP Status Code
"403": Forbidden "504": Gateway Time-out
Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 9
HTTP Response (Example)

HTTP/1.1 200 OK Response is 200 status code with OK message


using HTTP1.1

Date: Mon, 27 Jul 2009 Response Date & Time


12:28:53 GMT

Server: Apache/2.2.14 (Win32) Webserver used by server is Apache and version is


2.2.14 built for 32bit OS

Last-Modified: Wed, Last modified at Date & Time.


22 Jul 2009 19:15:56 GMT

Content-Length: 88 Content size of the response is 88 bytes

Content-Type: text/html Content type of the response is text file containing


HTML

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 10


Web Server
A web server is server software, that can satisfy client HTTP requests on the public World
Wide Web or also on private LANs and WANs.
The primary function of a web server is to store, process and deliver web pages to clients.
This primary function definition was good a few decades ago but nowadays it is better to use
the terms of Web contents and / or Web resources instead of Web Pages because it cover all
kind of contents that can be delivered to clients by web server.
Examples of Web contents may be HTML files, XHTML files, image files, style sheets,
scripts, other types of generic files that may be downloaded by clients, etc…
A user agent, commonly a web browser or web crawler, initiates communication by making a
request for a specific resource using HTTP and the server responds with the content of that
resource or an error message if unable to do so.
Commonly used web servers,
For PHP: Apache
For ASP: IIS
For JSP: Tomcat, Glassfish
Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 11
Apache web server
The Apache HTTP Server ("httpd") was launched in 1995 and it has been the most popular
web server on the Internet since April 1996.
We can download and install apache web server separately from
http://httpd.apache.org/download.cgi
We can also download Apache web server with bundle like XAMPP, WAMP or LAMP.
XAMPP is the most popular PHP development environment consist of Apache, MariaDB, PHP, Perl and
many other packages.
WAMP is popular PHP development environment for Windows OS.
LAMP is popular PHP development environment for Linux based OS.
We are going to use XAMPP bundle as it has installable versions of Windows as well as
Linux.
We can download XAMPP and install XAMPP from
https://www.apachefriends.org/index.html
In the next few slides we are going to see how to install and configure the XAMPP.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 12


Installing XAMPP
Step 01: Download XAMPP installable from https://www.apachefriends.org/index.html

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 13


Installing XAMPP (Cont.)
Step 02: start the installation by double clicking on the downloaded package
Note: you might get this warning before installation begins,
which suggest that UAC policy may restrict XAMPP
to perform some functions if we install it in C drive.
Press OK in this warning, as we are not going to install XAMPP on C drive.
After some screen you will get below screen, change the destination to other then C Drive.

After changing the destination of installation, just follow the default installation process.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 14


XAMPP Control Panel

Version of the
XAMPP

Ports used by
Started the service
Services
Services
Willavailable
be highlighted
InWith
XAMPPgreen
background

XAMPP Control Panel XAMPP Control Panel


(Windows) (Linux)

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 15


Configuring Server (Apache)
Sometimes we need to change the server configuration in some specific conditions like,
Port is occupied
To add/load modules
To change max upload size
To change root directory
Etc…
We can configure Apache server using httpd.conf file located at xampp/apache/conf folder.
We can configure some parameters of the server using php.ini file located at xampp/php
folder.
Important settings in httpd.conf file are,
Changing port number for apache : to change the port number for apache go to httpd.conf file and change
Listen:80 to any other available port number, we can also change port for https using httpd-ssl.conf file.
Loading/Unloading Modules in apache : to load/unload modules in apache we can go to httpd.conf and
remove/add the comment code(#) from the module we want to load/unload.
Changing Root Directory: to change root directory we can change DocumentRoot and <Directory> tag
to point new directory.
Prof. Arjun V. Bala #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 16
Configuring Server (Apache) (Cont.)
Important settings in php.ini file are,
upload_max_filesize setting is for the maximum allowed size for uploaded files in the scripts.
post_max_size setting is for the maximum allowed size of POST data that PHP will accept.
error_reporting = E_ALL & ~E_NOTICE setting has default values as E_ALL and ~E_NOTICE
which shows all errors except notices.
max_execution_time = 30, Maximum execution time is set to seconds for any script to limit the time in
production servers.
mysql.default_host = hostname setting is done to connect to MySQL with default server if no other
server host is mentioned.
mysql.default_user = username setting is done to connect MySQL with default username, if no
other name is mentioned.
mysql.default_password = password setting is done to connect MySQL with default password if
no other password is mentioned.

Prof. Vijay M Shekhat #3160713 (WP) ⬥ Unit 01 – Introduction to WEB 17


Web Programming (WP)
GTU # 3160713

Than
k
You
Prof. Vijay M. Shekhat
Computer Engineering Department
Darshan Institute of Engineering & Technology,
Rajkot
vijay.shekhat@darshan.ac.in
9558045778

You might also like