Web server

46

Transcript of Web server

Page 1: Web server
Page 2: Web server

Meeting Outline :

1. HTTP Server - Introduction & Working

2. Log Files to look out for in HTTP Server

3. Typical Configurations used on Server Side

4. Ongoing Projects and their Specific Logs

5. Existing Projects running CRON Jobs in the Background

Page 3: Web server

Domain Name System

Definition : Domain Name Servers (DNS) are the Internet's equivalent of a phone book. They maintain a directory of domain names and translate them to Internet Protocol (IP) addresses.This is necessary because, although domain names are easy for people to remember, computers or machines, access websites based on IP addresses. Example : When you visit http://dyn.com in a browser, your computer uses DNS to retrieve the website’s IP address of 204.13.248.115. Without DNS, you would only be able to visit any website (or any website) by visiting its IP address directly, such as http://204.13.248.115.

Page 4: Web server

How does DNS work ?

Page 5: Web server

HTTP Server

Page 6: Web server

HTTP Server Working

1. A user, via a web browser (HTTP client), issues a URL request to an HTTP server to start a webapp.

2. A client-side program (such as an HTML form) is loaded into client's browser.3. The user fills up the query criteria in the form.4. The client-side program sends the query parameters to a server-side program.5. The server-side program receives the query parameters, queries the database and

returns the query result to the client.6. The client-side program displays the query result on the browser.7. The process repeats.

Page 7: Web server

Different Responses by Server

1XX: Informational (def’d in 1.0, used in 1.1)100 Continue, 101 Switching Protocols2XX: Success 200 OK, 206 Partial Content3XX: Redirection 301 Moved Permanently, 304 Not Modified4XX: Client error 400 Bad Request, 403 Forbidden, 404 Not Found5XX: Server error 500 Internal Server Error, 503 Service Unavailable, 505 HTTP Version Not Supported

Page 8: Web server

HTTP Client-Server Communication with Intermediaries

1. The simple request/response pair between a client and server becomes more complex when intermediaries are placed in the virtual communication path between the client and server.

2. These are devices like proxies, gateways or tunnels that are used to improve performance & security or perform other necessary functions.

Page 9: Web server

Communication Process between Client-Server with Intermediary Devices

1. Client Request: The HTTP client sends a request message to the intermediary device.

2. Intermediary Request: The intermediary processes the request, making changes to it if necessary. It then forwards the request to the actual server.

3. Server Response: The server reads and interprets the request, takes appropriate action and then sends a response. Since it received its request from the intermediary, its reply goes back to the intermediary.

4. Intermediary Response: The intermediary processes the request, again possibly making changes, and then forwards it back to the client.

Page 10: Web server

Log Files to look out for in HTTP Server

Need for Log Files - In order to effectively manage a web server, it is necessary to get feedback about the activity and performance of the server as well as any problems that may be occurring. The Apache HTTP Server provides very comprehensive and flexible logging capabilities. This document describes how to configure its logging capabilities, and how to understand what the logs contain.The Following slides contain the type of Log Files maintained in an Apache HTTP Server.

Page 11: Web server

Types of Log Files

1. Error Log -a. The server error log, whose name and location is set by the ErrorLog

directive, is the most important log file. b. This is the place where Apache httpd will send diagnostic information and

record any errors that it encounters in processing requests. c. It is the first place to look when a problem occurs with starting the server or

with the operation of the server, since it will often contain details of what went wrong and how to fix it.

2. Access Log -a. The server access log records all requests processed by the server. b. The Access Log consists of two Related Directives - CustomLog and

LogFormat. The former controls the location and content, whereas the latter is used to simplify the contents of the Access Log.

Page 12: Web server

Other Log Files

1. PID File - On startup, Apache httpd saves the process id of the parent httpd process to the file logs/httpd.pid.

2. Script Log - In order to aid in debugging, the ScriptLog directive allows you to record the input to and output from CGI scripts. This should only be used in testing - not for live servers.

3. Rewrite Logs - When using the powerful and complex features of mod_rewrite, it is almost always necessary to use the RewriteLog to help in debugging. This log file produces a detailed analysis of how the rewriting engine transforms requests.

There are multiple ways in which these log files can be effectively used, it can be read about by visiting this site.

Page 13: Web server

Event Viewer in Windows OS

To view the Log Files in Windows OS, an application has been provided by Microsoft namely Event Viewer.

What is Event Viewer ?The Event Viewer is a tool that displays detailed information about significant events (for example, programs that don't start as expected or updates that are downloaded automatically) on your computer. It can be helpful when troubleshooting problems and errors with Windows and other programs.

Page 14: Web server

What Information Appears in Event Viewer ?

Event Viewer tracks information in several different logs. Windows Logs include:1. Application (program) events - Events are classified as error, warning, or

information, depending on the severity of the event.2. Security-related events - These events are called audits and are described as

successful or failed depending on the event, such as whether a user trying to log on to Windows was successful.

3. Setup events - Computers that are configured as domain controllers will have additional logs displayed here.

4. System events - System events are logged by Windows and Windows system services, and are classified as error, warning, or information.

Page 15: Web server

How to Open and Use Event Viewer?

The Event Viewer can be viewed and used in the following manner :1. Open Event Viewer by clicking the Start button Picture of the Start button,

clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Event Viewer. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

2. Click an event log in the left pane.3. Double-click an event to view the details of the event.

Page 16: Web server

Log Files and Their Locations in Windows

1. Log Files Location for Apache Server : C:\xampp\apache\logsThis is the location where the User can find the Access Logs and the Error Logs.

2. Log Files Location for PHP : C:\xampp\php\logsThis is the location where the User can find the Access Logs and the Error Logs.

Page 17: Web server

Log Files and Their Locations in Linux

1. Log Files Location for Apache Server :a. Error Logs : /var/log/httpd/error_logb. Access Logs : /var/log/httpd/access_log

2. Log Files Location for PHP : a. Error Logs : /var/log/php_errors.log

Page 18: Web server

How to View Log Files in Linux ?

Almost all log files are located under /var/log directory and its sub-directories on Linux. You can change to this directory using the cd command. You need be the root user to view or access log files on Linux or Unix like operating systems. Commands to View Log Files :1. less command 7. zgrep command2. more command 8. zmore command3. cat command4. grep command5. tail command6. zcat command

Page 19: Web server
Page 20: Web server
Page 21: Web server
Page 22: Web server
Page 23: Web server

httpd.conf

Definition:- httpd.conf is a configuration file which is used by the Apache HTTPServer. It stores

information on various functions of the server.Starting with apache 2.0, most of the configuration information is stored in this one fileThis file is present in :- C:\xampp\apache\conf\httpd.confother configuration information are placed in the xampp\apache\conf\extraThis file contains three types of information:- documentation (comments, which always follow the # symbol)directives – settings for various apache parameterssuch as DocumentRoot or CustomLog – these directives are system-wide – that is, they impact all of Apache

Page 24: Web server

httpd.confcontainers – directives that will take effect on specific entities such as directories, files or URLsThe httpd.conf file can be very largeyou can reduce its size by dividing the file into several files and use Include statements to attach other files to the main httpd.conf fileBasic Configuration Statements :-

Listen 80 - Allows you to bind Apache to specific IP addresses and/or ports.Example:- 0.0.0.0:80Accounts:-

● User ● Group

User/Group: The name (or #number) of the user/group to run httpd asExample:- user apache

Page 25: Web server
Page 26: Web server

httpd.conf

ServerName :- ServerName gives the name and port that the server uses to identify itself.Example:- localhost or sandra or shubham

DocumentRoot :- It defines where our web pages is located.Example:- c:/xampp/htdocs

Page 27: Web server

httpd.conf

Directory:- We have to specify/define/allow some permissions and options.Example:- ‘AllowOverride none’:- it specify that no one can change the options we had specified in this directory.‘Require all granted’ :- It allow any type of request.another example:-

Order allow,denyallow 192.160.0.0/24 (24 bits submask)

If a Control Access is given using IP Address, then only the local machine which have ip address between them is only permitted to have an access to the site.

Page 28: Web server
Page 29: Web server

httpd.conf

DirectoryIndex:- We direct apache to take index.html as default page. we can change it, if needed.

ErrorLog:- The location of the error log file.It is basically present in xampp/apache/logs.

If we do not define logs directories in <VirtualHost> then all project errors also generatehere.

Page 30: Web server

httpd.conf

<Location / server-status>Sethandler server-statusOrder allow,denyallow from 192.168.0.85 (Only allow this ip to access to the file)

<Location>This file include details like TIME and DATE the server has been up for.192.168.0.85/server-info192.168.0.85/server-status

Note :- we need mod_status.so LoadModule to include in httpd.conf to use above functionality.

Page 31: Web server
Page 32: Web server

httpd.confApache modules are installed like any other piece of software. Fortunately Apache comes prebuilt with a number of common modules

LoadModule :- This keywords tells apache that which modules it have to load.

Location:- xampp/apache/modulesFew Examples:-mod_authz_host.so :- For control access by ip address. Basically use when we prevent our server to access by outer world.mod_dir.so :- which allow to set a default web page. normally its index.htmlmod_info.so :- This allow us to get information of server. mod_status.so:- This allow us to get the status.

Page 33: Web server
Page 34: Web server

httpd.conf

Include :- Included to add extra features or to modify the default configuration of the server, or you may simply copy their contents here and change as necessary.

Page 35: Web server
Page 36: Web server

Create php file to test server

test.php<?php

phpinfo();?>Place this file in htdocs. Now start the Apache Server and hit following URL in the browser:-localhost/test.php. This will give us all heap of information.

Page 37: Web server
Page 38: Web server

php.iniThe php.ini file is where you declare changes to your PHP settings. You can use the default settings for the server or change specific settings by editing the php.ini file.

This file is present in :- C:\xampp\php\php.inishort_open_tag = OffShort open tags look like this: <? ?>. This option should be set to Off, In that case we should use <?php ?> which is standard.If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?>max_execution_time = 30The function set_time_limit() won't work in safe mode, so this is the main way to make a script timeout in safe mode. In Windows, you have to abort based on maximum memory consumed rather than time. You can also use the Apache timeout setting to timeout if you use Apache, but that will apply to non-PHP files on the site too.

Page 39: Web server

php.ini

file_uploads = [on/off]Turn on this flag if you will upload files using PHP script.

memory_limit=128MMaximum amount of memory a script may consume

log_errors=OnBesides displaying errors, PHP can also log errors to locations.

Page 40: Web server

php.ini

html_errors=OnWhen PHP displays or logs an error, it has the capability of inserting html links to documentation related to that error.

error_log="C:\xampp\php\logs\php_error_log"Log errors to specified file. PHP's default behavior is to leave this value empty.

post_max_size=8000MMaximum size of POST data that PHP will accept.

mysql.default_port=3306Default port number for mysql_connect().

Page 41: Web server

php.iniupload_max_filesize=2000MMaximum allowed size for uploaded files.

max_file_uploads=2000 Maximum number of files that can be uploaded via a single request

date.timezone=Europe/BerlinDefines the default timezone used by the date functions

mysql.cache_size=200000If mysqlnd is used: Number of cache slots for the internal result set

cache

Page 42: Web server

Current project -MPC’s application specific logs

Error logging in CodeIgniter (PHP)

Page 43: Web server

cron

Definition :- The software utility Cron is a time-based job scheduler in

Unix-like computer operating systems. People who set up and maintain

software environments use cron to schedule jobs (commands or shell scripts)

to run periodically at fixed times, dates, or intervals.

For windows we can use windows Scheduler

Page 44: Web server
Page 45: Web server
Page 46: Web server

Any Questions?

Thanks :)