apache http server (servidor http). servidor web - apache o apache é um servidor web gratuito fonte...

73
Apache HTTP Server (Servidor HTTP)

Upload: internet

Post on 17-Apr-2015

151 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Apache

HTTP Server(Servidor HTTP)

Page 2: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Servidor Web - Apache

O Apache é um servidor Web gratuito

fonte aberta robusto altamente confiável configurável extensível

Page 3: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Servidor Web

O grande propósito de um servidor WEB é receber e processar requisições via protocolo HTTP.

Inicialmente o objetivo era servir páginas estáticas.

Depois surgiram as páginas dinâmicas e interativas.

Page 4: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Modelo Request/Response

Cliente Servidor Web

Solicitação HTTP

Dados HTML

Page 5: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Modelo Request/Response

Browser Servidor Webrequest

response

Exemplos:Mozilla Firefox

Internet ExplorerChrome (Google)

OperaKonqueror

Safari

Exemplos:Apache

Internet Information Server (IIS)lighttpd

Page 6: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Modelo Request/Response

Page 7: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Protocolo HTTP (HyperText Transport Protocol)

É um protocolo da camada de aplicação que usa TCP como protocolo de transporte

É um protocolo “stateless”, isto é, sem estado, sendo cada requisição independente uma das outras.

Page 8: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Requisição HTTP

GET / HTTP/1.1Host: www.policamp.edu.brUser-Agent: Mozilla/5.0 ...Connection: Keep-Alive

Page 9: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Resposta HTTP

HTTP/1.1 200 OKDate: Thu, 16 Aug 2007 22:46:38 GMTContent-Type: text-htmlContent-Lenght: 2541

<html>...

Page 10: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

URI (Universal Resource Identifier)

URIs são strings utilizadas para identificar recursos na Web como páginas, serviços, documentos, imagens, musicas, arquivos, caixas de emails, noticias, entre outros. O URL (Universal Resource Locator) é um tipo de URI.

Page 11: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

URI (Uniform Resource Identifier)ftp://ftp.is.co.za/rfc/rfc1808.txt -- ftp scheme for File Transfer Protocol services

gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles-- gopher scheme for Gopher and Gopher+ Protocol services

http://www.math.uio.no/faq/compression-faq/part1.html -- http scheme for Hypertext Transfer Protocol services

mailto:[email protected] mailto scheme for electronic mail addresses

news:comp.infosystems.www.servers.unix -- news scheme for USENET news groups and articles

telnet://melvyl.ucop.edu/ -- telnet scheme for interactive services via the TELNET Protocol

Page 12: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

URL (Uniform Resource Locator)

<scheme>:://<host>/<path>Exemplo: http://www.policamp.edu.brOnde:<scheme> = indica qual o serviço

solicitado (http, ftp, etc)<host> = www.policamp.edu.br<path> = /

Page 13: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Evolução da páginas dinâmicas

CGI (Common Gateway Interface) FastCGI Apache Modules (exemplos:

mod_php, mod_ruby, ...)

Page 14: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Versões do Apache

Apache 1.3.33 Apache 2.0 Apache 2.2

Page 15: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Instalação do Apache (Linux)

Faça o download http://httpd.apache.org

tar –xzvf httpd-2.0.59.tar.gz

Page 16: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Instalação do Apache (2)

$ ./configure –prefix=/usr/local/apache2

$ make$ make install$ /usr/local/apache2/bin/apache2ctl

start

Page 17: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Documentação do Apache (1) Compiling and Installing (Compilação e instalação) Starting (Iniciando) Stopping or Restarting ( Run-time Configuration Directives Directive Quick-Reference Modules (Módulos) Multi-Processing Modules (MPMs) Filters (Filtros) Handlers Server and Supporting Programs (Servidores e

programas de Suporte) Glossary

Page 18: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Documentação do Apache (2)

Release Notes (Notas da Versão) Reference Manual (Manual de

Referência) User’s Guide (Guia do Usuário) How-To / Tutorials

Page 19: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Programas httpd

Servidor HTTP (hypertext transfer protocol server) apachectl

Interface de controle do servidor HTTP Apache ab

Apache HTTP server benchmarking tool apxs

APache eXtenSion tool configure

Configure the source tree dbmmanage

Create and update user authentication files in DBM format for basic authentication

Page 20: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Programas (2) htdigest

Create and update user authentication files for digest authentication

htdbm Manipulate DBM password databases.

htpasswd Create and update user authentication files for basic

authentication logresolve

Resolve hostnames for IP-addresses in Apache logfiles rotatelogs

Rotate Apache logs without having to kill the server suexec

Switch User For Exec Other Programs

Support tools with no own manual page.

Page 21: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Apache – Arquivos de configuração

/var/log/apache2 /etc/apache2

apache2.conf cond.d httpd.conf principal arquivo de

configuração ports.conf

/usr/sbin/apache2

Page 22: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de Configuração

Principais arquivos de configuração Sintaxe dos arquivos de

configuração Módulos Escopo das Diretivas Arquivos .htaccess

Page 23: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de Configuração /etc/apache2

apache2.conf conf.d/ envvars httpd.conf mod-available/ mods-enabled/ ports.conf sites-available/ sites-enabled/

Page 24: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de Configuração /usr/sbin/apache2 /usr/sbin/apache2ctl

/etc/init.d/apache2 /etc/default/apache2

/usr/lib/apache2 /usr/share/apache2

Page 25: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de Configuração

Arquivo /etc/init.d/apache2 (usado principalmente em distribuições Debian e derivadas)

/etc/init.d/httpd (usadas em outras distribuições e recomendada pela Apache)

maurocl@ubuntu-server:/etc/init.d$ ./apache2 * Usage: /etc/init.d/apache2 {start|stop|restart|

reload|force-reload}

Page 26: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

apache2.conf

É o principal arquivo de configuração do Apache2

Page 27: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Ports.conf

No Apache2 a configuração de portas é feita pelo arquivo /etc/apache2/ports.conf

Page 28: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Aliases de interfaces de rede

Para tornar permanente os aliases de interfaces de rede é necessário alterar o arquivo

/etc/init.d/bootmisc.sh /etc/rd.d/rc.local

Essa mudança depende da distribuição do Linux usada.

Page 29: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de Log

/var/log/apache2/error.log log de erros

/var/log/apache2/access.log log de acessos

Diretório ‘default’ /var/www/apache2-default

Page 30: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Access Log

Loga as informações referentes a quem está acessando o servidor

As informações são registradas no formato CLF (Common Log Format)

Page 31: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

access.log cat access_log192.168.7.14 - - [16/Sep/2008:16:58:23 -0300] "GET / HTTP/1.1" 403 3918 "-" "Mozilla/5.0

(Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"192.168.7.14 - - [16/Sep/2008:16:58:23 -0300] "GET /icons/apache_pb2.gif HTTP/1.1" 200 2414

"http://192.168.7.30/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:16:58:23 -0300] "GET /icons/poweredby.png HTTP/1.1" 200 3034 "http://192.168.7.30/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:16:58:24 -0300] "GET /favicon.ico HTTP/1.1" 404 286 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:16:58:27 -0300] "GET /favicon.ico HTTP/1.1" 404 286 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:17:04:02 -0300] "GET /perl-status HTTP/1.1" 403 290 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:17:04:12 -0300] "GET /perl-status/ HTTP/1.1" 403 291 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

192.168.7.14 - - [16/Sep/2008:17:06:24 -0300] "GET /perl/test.pl HTTP/1.1" 200 14 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

Page 32: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Error Log

O arquivo errorlog registra o log de erros do Apache.

Page 33: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

error.logcat error_log[Tue Sep 16 16:57:57 2008] [notice] SELinux policy enabled; httpd running as context

unconfined_u:system_r:httpd_t:s0[Tue Sep 16 16:57:57 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)[Tue Sep 16 16:57:58 2008] [notice] Digest: generating secret for digest authentication ...[Tue Sep 16 16:57:58 2008] [notice] Digest: done[Tue Sep 16 16:57:59 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max

threads.[Tue Sep 16 16:57:59 2008] [notice] mod_python: using mutex_directory /tmp[Tue Sep 16 16:57:59 2008] [notice] Apache/2.2.8 (Unix) DAV/2 PHP/5.2.5 mod_python/3.3.1 Python/2.5.1

mod_ssl/2.2.8 OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.10.0 configured -- resuming normal operations[Tue Sep 16 16:58:23 2008] [error] [client 192.168.7.14] Directory index forbidden by Options directive:

/var/www/html/[Tue Sep 16 16:58:24 2008] [error] [client 192.168.7.14] File does not exist: /var/www/html/favicon.ico[Tue Sep 16 16:58:27 2008] [error] [client 192.168.7.14] File does not exist: /var/www/html/favicon.ico[Tue Sep 16 17:03:31 2008] [notice] SIGHUP received. Attempting to restart[Tue Sep 16 17:03:31 2008] [notice] Digest: generating secret for digest authentication ...[Tue Sep 16 17:03:31 2008] [notice] Digest: done[Tue Sep 16 17:03:31 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max

threads.[Tue Sep 16 17:03:31 2008] [notice] mod_python: using mutex_directory /tmp[Tue Sep 16 17:03:31 2008] [notice] Apache/2.2.8 (Unix) DAV/2 PHP/5.2.5 mod_python/3.3.1 Python/2.5.1

mod_ssl/2.2.8 OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.10.0 configured -- resuming normal operations[Tue Sep 16 17:04:02 2008] [error] [client 192.168.7.14] client denied by server configuration: /var/www/html/perl-

status[Tue Sep 16 17:04:12 2008] [error] [client 192.168.7.14] client denied by server configuration: /var/www/html/perl-

status

Page 34: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Processos$ ps aux | grep apache

root@ubuntu-server:/var/www/apache2-default# ps aux | grep apacheroot 3896 0.0 2.3 20016 5996 ? Ss 19:44 0:00

/usr/sbin/apache2 -k startwww-data 3915 0.0 1.2 20016 3208 ? S 19:44 0:00

/usr/sbin/apache2 -k startwww-data 3916 0.0 1.2 20016 3208 ? S 19:44 0:00

/usr/sbin/apache2 -k startwww-data 3917 0.0 1.2 20016 3208 ? S 19:44 0:00

/usr/sbin/apache2 -k startwww-data 3918 0.0 1.2 20016 3208 ? S 19:44 0:00

/usr/sbin/apache2 -k startwww-data 3919 0.0 1.2 20016 3208 ? S 19:44 0:00

/usr/sbin/apache2 -k start

Page 35: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Versão do Apache instalada

root@ubuntu-server:~# apache2ctl -v

Server version: Apache/2.2.3Server built: Jan 15 2007 18:14:50

Page 36: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Versão do Apache instalado (detalhado)

root@ubuntu-server:~# apache2ctl -VServer version: Apache/2.2.3Server built: Jan 15 2007 18:14:50Server's Module Magic Number: 20051115:3Server loaded: APR 1.2.7, APR-Util 1.2.7Compiled using: APR 1.2.7, APR-Util 1.2.7Architecture: 32-bitServer MPM: Prefork threaded: no forked: yes (variable process count)

Page 37: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Versão do Apache instalado (detalhado) (2)Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

Page 38: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Alias de diretórios

http://192.168.7.15/icons/

Page 39: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Estatística de uso dos Web Servers Resultados da pesquisa de agosto do Netcraft

mostram nova redução do percentual do Apache - "A liderança do Apache nas estatísticas de servidores web mantidas pelo Netcraft continua inquestionável, embora em declínio continuado. Os dados de agosto mostram mais uma pequena redução, e agora o m" (continua...)

Para saber mais, visite o BR-Linux (http://br-linux.org/).

Page 40: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Uso de Servidores web

Apache 48,4%IIS 34,2%Outros 17,4%

FonteFonte: : http://br-linux.org/linux/resultados-da-pesquisa-de-agosto-do-netcraft

Page 41: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Apache cresce ainda mais no mercado de servidores As estatísticas de servidores web liberadas mensalmente

pela Netcraft mostram que o servidor livre Apache opera, agora, 1,2 milhões de sites a mais que há um mês.

Isso significa que o servidor web de código aberto está por trás de 176.748.506 dos websites pesquisados, quase metade de toda a amostra. Em segundo lugar na lista está o Microsoft IIS, com uma fatia de 35%, seguido do Google Web Server (GWS) com 6% e do Lighttpd, também de código aberto, com 3% (1,7 milhões de sites).

Segundo a Netcraft, uma nova promessa é o servidor Nginx, de autoria do programador russo Igor Sysoev. Em sua primeira aparição na lista, ele já alcançou o quinto lugar. As estatísticas estão disponíveis no site da Netcraft. O ranking de servidores de agosto está aqui.

Publicado em 01/09/2008 às 10:45 em http://www.linuxnewmedia.com.br/noticia/apache_cresce_ainda_mais_no_mercado_de_servidores

Page 42: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Netcraft Web Server Survey

http://survey.netcraft.com/Reports/200808/

Page 43: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

WebDAV (Web-based Distributed and Versioning)

É uma extensão ao HTTP Permite criar, copiar, mover ou

excluir arquivos em um servidor Web

Módulo mod_dev

Page 44: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Módulos

O Apache é um sistema divido em módulos

Apenas um conjunto mínimo de módulos são carregados no núcleo do servidor http

Outras funcionalidades são acrescentadas por meio de outros módulos

Page 45: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Módulos (2)

Módulo worker worker.cmod_auth mod_auth.cmpm_winnt mpm_winnt.cOs módulos podem ser compilados

junto com o Apache ou carregados dinamicamente

Page 46: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Módulos (3)

mpm_prefork Apache estruturado em processos

mpm_worker Apache estruturado em threads

Page 47: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Suporte a Dynamic Shared Object (DSO)

São módulos que podem ser carregados dinamicamente

Um módulo é definido como DSO no momento em que se está definindo a compilação do Apache

Page 48: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Status de um Módulo

Núcleo (N) MPM (multi-processamento) (M) Base (B) Extensão (E) Experimental (X)

Page 49: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Core Features and Multi-Processing Modules

core Core Apache HTTP Server features that are always available

mpm_common A collection of directives that are implemented by more than one multi-

processing module (MPM)

beos This Multi-Processing Module is optimized for BeOS.

event An experimental variant of the standard worker MPM

mpm_netware Multi-Processing Module implementing an exclusively threaded web

server optimized for Novell NetWare

Page 50: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Core Features and Multi-Processing Modulesmpmt_os2 Hybrid multi-process, multi-threaded MPM for OS/2

prefork Implements a non-threaded, pre-forking web server

mpm_winnt Este módulo Multi-Processing é otimizado para Windows

NT.

worker Multi-Processing Module implementing a hybrid multi-

threaded multi-process web server

Page 51: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Lista de Módulos

Veja http://httpd.apache.org/docs/2.2/mod/

Page 52: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Exemplos de Módulos mod_rewrite: provê um engine (“motor”)

para reescrver URLs requisitadas sob demanda

mod_deflate: comprime o conteúdo antes de enviar ao cliente

mod_cband: controla a largura de banda usada

mod_speling: tenta corrigir URLs com erros que o usuário fez por engano, como esquecer de acrescentar um ‘s’ a site, ou ignorando a questão de letras maiúsculas e minúsculas.

Page 53: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Código de Status do HTTP

Informativos (1XX) Requisição bem sucedida (2XX) Redirecionamento (3xx) Erro na requisição do cliente (4XX) Erro do servidor (5XX)

Page 54: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Autenticação no Apache

AccessFileName (.htaccess) AllowOverride AuthType AuthName Require Satisfy

Page 55: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Autenticação (2)

.httpasswd .htaces Utilitário htpasswd:

# ./htpasswd –c .htpasswd <username>

Page 56: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Modelo CGI (Common Gateway Interface)

O usuário acessa uma URL Essa URL indica a necessidade de

execução de um programa externo via CGI

O servidor Web carrega o programa, redireciona a requisição, aguarda o processamento e recebe a resposta que é enviada de volta ao usuário.

Page 57: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

CGI (Common Gateway Interface)

CGI define uma forma para o servidor web interagir com programas externos que geram conteúdo dinamicamente. Esses programas são frequentemente chamados programas CGI ou scripts CGI. É a maneira mais simples e mais comum de colocar conteúdo dinâmico em um site na web.

Page 58: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Servidor LAMP / WAMP / MAMP

Linux / Windows / Mac Apache MySQL PHP

Page 59: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Exemplo de execução de um script PHP com acesso a base de dados MySQL

Page 60: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

DocumentRoot (raiz da localização dos arquivos)

/var/www/html

Page 61: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Estrutura de diretórios[root@localhost httpd]# find $PWD/etc/httpd/etc/httpd/logs/etc/httpd/run/etc/httpd/conf/etc/httpd/conf/magic/etc/httpd/conf/httpd.conf/etc/httpd/conf.d/etc/httpd/conf.d/proxy_ajp.conf/etc/httpd/conf.d/manual.conf/etc/httpd/conf.d/ssl.conf/etc/httpd/conf.d/perl.conf/etc/httpd/conf.d/welcome.conf/etc/httpd/conf.d/webalizer.conf/etc/httpd/conf.d/README/etc/httpd/conf.d/perl.conf~/etc/httpd/conf.d/python.conf/etc/httpd/conf.d/php.conf/etc/httpd/conf.d/squid.conf/etc/httpd/modules

Page 62: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Arquivos de log /var/log/httpd[root@localhost httpd]# lltotal 24-rw-r--r-- 1 root root 1536 2008-09-16 17:06 access_log-rw-r--r-- 1 root root 2792 2008-09-10 16:43 access_log-20080914-rw-r--r-- 1 root root 1931 2008-09-16 17:04 error_log-rw-r--r-- 1 root root 3730 2008-09-10 16:43 error_log-20080914-rw-r--r-- 1 root root 0 2008-09-07 16:54 ssl_access_log-rw-r--r-- 1 root root 333 2008-09-16 17:03 ssl_error_log-rw-r--r-- 1 root root 1140 2008-09-10 16:43 ssl_error_log-20080914-rw-r--r-- 1 root root 0 2008-09-07 16:54 ssl_request_log

Page 63: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

httpd.conf

Arquivo principal de configuração do Apache

localizado em /etc/httpd/conf/

Page 64: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Configuração do Apache

As diretivas de configuração estão agrupadas em três sessões básicas: global_environment (configuração

global do servidor Apache) diretivas que definem os parâmetros

do servidor principal (main) ou padrão configurações para Hosts Virtuais

(Virtual Hosts)

Page 65: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Sessão 1 – Global Environment Sessão 2 – Main server

configuration Sessão 3 – Virtual Hosts

Page 66: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Variáveis de Ambiente

Page 67: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Sites seguros com SSL (Secure Socket Layer)

Um certificado SSL é normalmente emitido por uma Autoridade Certificadora (Certified Authority (CA)) – garante a identidade do servidor Web em questão.

Conexão segura HTTPS (HTTP seguro)

Page 68: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Conexões SeguraCliente Servidor

1. Cliente solicita uma conexão segura através de uma URL https://...

2. Antes de estabelecer uma conexão o servidor envia o CA ao cliente

1. Se o certificado emitido não for autêntico para o domínio pelo qual response uma msg de alerta será exibida no cliente

2. Se o certificado for válido a conexão continuará. Uma chave é criada para sessão e enviada ao servidor. Essa chave é criptografada utilizando a chave publica do servidor

3. O servidor decodifica a chave da sessão utilizando sua chave privada. A partir desse momento, todo o conteúdo da conexão será criptografado por essa sessão, que é de conhecimento exclusivo do cliente e do servidor em questão

Page 69: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Criação do Certificado

Algumas CAs que fornecem certificados para servidores Web são: Thawte VeriSign GoDaddy

A emissão de certificados é um serviço pago.

A CAcert emite certificados gratuitamente.

Page 70: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Instalação do Certificado

Page 71: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Conexão Segura – Protocolo SSL

Porta 443 corresponde ao protocolo SSL utilizado na conexão segura

Page 72: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Bibliografia

[1] MARCELO, A. Apache – Configurando o Servidor Web para Linux. 2ª edição. Rio de Janeiro: Brasport, 2006.

[2] VEIGA, R.G.A. Apache – Guia de Consulta Rápida. São Paulo: Novatec, 2006.

Page 73: Apache HTTP Server (Servidor HTTP). Servidor Web - Apache O Apache é um servidor Web gratuito fonte aberta robusto altamente confiável configurável extensível

Links

[1] http://www.cacert.org/