1 / 73

Apache

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.

Download Presentation

Apache

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Apache HTTP Server (Servidor HTTP)

  2. Servidor Web - Apache • O Apache é um servidor Web gratuito • fonte aberta • robusto • altamente confiável • configurável • extensível

  3. 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.

  4. Solicitação HTTP Cliente Servidor Web Dados HTML Modelo Request/Response

  5. request Browser Servidor Web response Modelo Request/Response Exemplos: Mozilla Firefox Internet Explorer Chrome (Google) Opera Konqueror Safari Exemplos: Apache Internet Information Server (IIS) lighttpd

  6. Modelo Request/Response

  7. 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.

  8. Requisição HTTP GET / HTTP/1.1 Host: www.policamp.edu.br User-Agent: Mozilla/5.0 ... Connection: Keep-Alive

  9. Resposta HTTP HTTP/1.1 200 OK Date: Thu, 16 Aug 2007 22:46:38 GMT Content-Type: text-html Content-Lenght: 2541 <html> ...

  10. 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.

  11. 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:mduerst@ifi.unizh.ch -- 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

  12. URL (Uniform Resource Locator) <scheme>:://<host>/<path> Exemplo: http://www.policamp.edu.br Onde: <scheme> = indica qual o serviço solicitado (http, ftp, etc) <host> = www.policamp.edu.br <path> = /

  13. Evolução da páginas dinâmicas • CGI (Common Gateway Interface) • FastCGI • Apache Modules (exemplos: mod_php, mod_ruby, ...)

  14. Versões do Apache • Apache 1.3.33 • Apache 2.0 • Apache 2.2

  15. Instalação do Apache (Linux) • Faça o download http://httpd.apache.org • tar –xzvf httpd-2.0.59.tar.gz

  16. Instalação do Apache (2) $ ./configure –prefix=/usr/local/apache2 $ make $ make install $ /usr/local/apache2/bin/apache2ctl start

  17. 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

  18. 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

  19. 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

  20. 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.

  21. 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

  22. Arquivos de Configuração • Principais arquivos de configuração • Sintaxe dos arquivos de configuração • Módulos • Escopo das Diretivas • Arquivos .htaccess

  23. Arquivos de Configuração • /etc/apache2 • apache2.conf • conf.d/ • envvars • httpd.conf • mod-available/ • mods-enabled/ • ports.conf • sites-available/ • sites-enabled/

  24. Arquivos de Configuração • /usr/sbin/apache2 • /usr/sbin/apache2ctl • /etc/init.d/apache2 • /etc/default/apache2 • /usr/lib/apache2 • /usr/share/apache2

  25. 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}

  26. apache2.conf • É o principal arquivo de configuração do Apache2

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

  28. 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.

  29. 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

  30. 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)

  31. access.log cat access_log 192.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"

  32. Error Log • O arquivo errorlog registra o log de erros do Apache.

  33. error.log cat 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

  34. Processos $ ps aux | grep apache root@ubuntu-server:/var/www/apache2-default# ps aux | grep apache root 3896 0.0 2.3 20016 5996 ? Ss 19:44 0:00 /usr/sbin/apache2 -k start www-data 3915 0.0 1.2 20016 3208 ? S 19:44 0:00 /usr/sbin/apache2 -k start www-data 3916 0.0 1.2 20016 3208 ? S 19:44 0:00 /usr/sbin/apache2 -k start www-data 3917 0.0 1.2 20016 3208 ? S 19:44 0:00 /usr/sbin/apache2 -k start www-data 3918 0.0 1.2 20016 3208 ? S 19:44 0:00 /usr/sbin/apache2 -k start www-data 3919 0.0 1.2 20016 3208 ? S 19:44 0:00 /usr/sbin/apache2 -k start

  35. Versão do Apache instalada root@ubuntu-server:~# apache2ctl -v Server version: Apache/2.2.3 Server built: Jan 15 2007 18:14:50

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

  37. 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"

  38. Alias de diretórios • http://192.168.7.15/icons/

  39. 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/).

  40. Uso de Servidores web Apache 48,4% IIS 34,2% Outros 17,4% Fonte: http://br-linux.org/linux/resultados-da-pesquisa-de-agosto-do-netcraft

  41. 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

  42. Netcraft Web Server Survey • http://survey.netcraft.com/Reports/200808/

  43. 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

  44. 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

  45. Módulos (2) Módulo worker  worker.c mod_auth  mod_auth.c mpm_winnt  mpm_winnt.c Os módulos podem ser compilados junto com o Apache ou carregados dinamicamente

  46. Módulos (3) • mpm_prefork  Apache estruturado em processos • mpm_worker  Apache estruturado em threads

  47. 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

  48. Status de um Módulo • Núcleo (N) • MPM (multi-processamento) (M) • Base (B) • Extensão (E) • Experimental (X)

  49. 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

  50. Core Features and Multi-Processing Modules mpmt_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

More Related