Apache
*******************************************************************************
Instalar e Configurar o Apache no Debian e OpenSuse
Criado por: Alessandro C. M. Kuramoto
Data: 01/12/2008
Modificado em: 06/10/2009-22:06
v.20091006-2206
Palavras-chaves: apache
If you want to know something about this file, send an e-mail to me at the
sancmk@gmail.com or post a comment here (at the Word Press)
moshi kono fairu no koto wo shiteitakatara, boku ni email wo okutte kudasai,
matawa kono Word Press ni chuushaku mo shitte ii desu.
boku no email wa sancmk@gmail.com desu
Por favor, matenham o nome do autor deste arquivo.
*******************************************************************************
###############################################################################
# Avisos!!!
###############################################################################
http://memovirtual.worpress.com
## Atenção no site memovirtual:
## As opções passadas com – - (menos,menos) no site podem ter ficado
## com um — (travessão), assim use o “man” para confirmar a opção utilizada
## Desculpem-me pelos erros de português, mas vocês sabem…
## nossa lingua é fácil… e às vezes ao escrever o pensamento está
## lá na frente, enquanto que a digitação…
|##########^ Avisos!!! #######################################################|
###############################################################################
# Temp:
###############################################################################
>Temp
|##########^ Temp ############################################################|
###############################################################################
# Servidor:
###############################################################################
|##########^ Servidor ########################################################|
###############################################################################
# Conceitos:
###############################################################################
|<<<<<<<<<<<<<< #### Conceitos ####
|##########^ Conceitos #######################################################|
###############################################################################
# Instalando:
###############################################################################
>Instalando
===============================================================================
Instalando o Apache no Debian:
===============================================================================
|<<<<<<<<<<<<<< #### Instalando ####
|<<<<<<<<<<<<<< ==== Instalando o Apache no Debian ====
## Primeiro
## Atualizar a lista de pacotes
apt-get update
## Instalar o Apache:
apt-get install apache2
## CUIDADO: O comando apt-get install apache irá instalar o apache 1.3
## OBS: o pacote apache-common ou o apache2.2-common tem os arquivos
## de configuração do Apache.
|==========^ Instalando o Apache no Debian ===================================|
===============================================================================
Instalando o Apache no SUSE:
===============================================================================
|<<<<<<<<<<<<<< #### Instalando ####
|<<<<<<<<<<<<<< ==== Instalando o Apache no SUSE ====
Método 1)
### Entrar no gerenciamento de software do YaST:
yast sw_single
### Selecionar:
Filter > Search > Digitar: apache2 > Apertar a tecla de Espaço > Selecionar: [Accept]
|<<<<<<<<<<<<<< #### Instalando ####
|<<<<<<<<<<<<<< ==== Instalando o Apache no SUSE ====
————————–
Método 2)
zypper install apache2
|==========^ Instalando o Apache no SUSE =====================================|
|##########^ Instalando ######################################################|
###############################################################################
# Arquivos de Configuração do Apache:
###############################################################################
### Debian: /etc/apache2/apache2.conf
## Inclui as configurações de módulos:
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
###############################################################################
# Configurando:
###############################################################################
===============================================================================
Configuração Geral – Parâmetros Gerais de Configuração – Explicação:
===============================================================================
## e-mail do administrador do servidor:
ServerAdmin alessandrocmk@gmail.com
## Nome do servidor:
ServerName localhost
## Arquivos iniciais:
DirectoryIndex start.html index.html index.html.var
|=============================================================================|
===============================================================================
Configuração Geral – Explicação:
===============================================================================
_______________________________________________________________________________
Debian
Arquivo: /etc/apache2/apache2.conf (Permissões: -rw-r–r– 1 root root)
——————————————————————————-
.
..
…
### Implementação de segurança no servidor apache:
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is ‘Full’ which sends information about the OS-Type
# and compiled in modules.
# Set to one of: Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
#ServerTokens Full
ServerTokens Prod
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to “EMail” to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
#ServerSignature On
ServerSignature Off
…
..
.
|———-^ Arquivo: /etc/apache2/apache2.conf ——————————|
===============================================================================
Configuração do DirectoryIndex:
===============================================================================
## O DirectoryIndex é a diretiva do primeiro arquivo que será lido
## na apresentação da página:
_______________________________________________________________________________
Debian
Arquivo: /etc/apache2/mods-enabled/dir.conf (Permissões: -rw-r–r– 1 root root)
——————————————————————————-
<IfModule mod_dir.c>
DirectoryIndex index.shtml index.html index.cgi index.pl index.php index.xhtml
</IfModule>
+—————————————————————————–|
###############################################################################
# Configurar SSL no Apache (Apache com SSL): #
###############################################################################
## (Fonte: http://penguim.wordpress.com/2008/07/14/habilitando-ssl-no-apache2/)
## Para instalar os pacotes de SSL:
aptitude install openssl ssl-cert
## Criar um Certificado para o Apache:
openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem
Ou
openssl req -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem
### Os seguintes dados serão solicitados:
# Inserir a sigla do país:
Country Name (2 letter code) [AU]:BR
# O nome do estado:
State or Province Name (full name) [Some-State]:Distrito Federal
# O nome da cidade:
Locality Name (eg, city) []:Brasilia
# O nome da organização/instituição:
Organization Name (eg, company) [Internet Widgits Pty Ltd]: Nome
Organizational Unit Name (eg, section) []:
Email Address []:suporte@dominio.com.br
## Dar a permissão necessária ao certificado:
chmod 600 /etc/apache2/apache.pem
## No Debian, edite o arquivo /etc/apache2/ports.conf e adicione a seguinte linha:
vim /etc/apache2/ports.conf
——– /etc/apache2/ports.conf ——————————–
## Adicione a linha abaixo:
Listen 443
|——–^ /etc/apache2/ports.conf ——————————
—–
### Habilitar o módulo de SSL
## Habilite o suporte a SSL no apache2 da seguinte forma:
a2enmod ssl
Ou
cd /etc/apache2/mods-enabled
ln -s ../mods-available/ssl.conf
ln -s ../mods-available/ssl.load
——-|
## Faça uma cópia do arquivo /etc/apache2/sites-available/default com o nome ssl.
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/sites-ssl
## Faça um link simbólico para /etc/apache2/sites-enabled:
ln -s /etc/apache2/sites-available/sites-ssl /etc/apache2/sites-enabled/
## Edite o arquivo /etc/apache2/sites-enabled/sites-ssl, adicionando as
## seguintes linhas:
vim /etc/apache2/sites-enabled/sites-ssl
——– /etc/apache2/sites-enabled/sites-ssl ——————————–
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin webmaster@localhost
…..
### Adicione esta linha
## Habilita o Engine do SSL para o Site:
SSLEngine on
ServerSignature On
## Indicar o caminho para o arquivo .crt
## (O certificado auto-assinado)
SSLCertificateFile /etc/apache2/apache.pem
…
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
…
Alias /ldap/ “/var/www/chpassldapweb/”
<Directory “/var/www/chpassldapweb”>
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
…
CustomLog /var/log/apache2/access.log combined
SSLCertificateFile /etc/apache2/apache.pem #Adicione esta linha
</VirtualHost>
|——–^ /etc/apache2/sites-enabled/sites-ssl —————————–|
## Reinicie o Apache:
apache2ctl restart
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Arquivos de Configuração:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## O site que com SSL deve ter as entradas abaixo:
Exemplo: /etc/apache2/sites-enabled/site-ssl
———————————————————
NameVirtualHost *:443
<VirtualHost *:443>
ServerName webmail.dominio.com.br
.
.
## Habilita o Engine do SSL para o Site:
SSLEngine on
## Indicar o caminho para o arquivo .crt
## (O certificado auto-assinado)
SSLCertificateFile /etc/apache2/apache.pem
.
.
</VirtualHost>
———————————————————
ServerRoot “/etc/apache2″
User www-data
Group www-data
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Após criar o certificado e editar os arquivo é necessário reiniciar o
## serviço:
/etc/init.d/apache2 restart
###############################################################################
# Fazer Redirecionamento:
###############################################################################
# RedirectMatch ^/$ /apache2-default/
RedirectMatch ^/$ /novosite/
#### Referências:
http://focalinux.cipsga.org.br/guia/avancado/ch-s-apache.htm
|##########^ Fazer Redirecionamento ##########################################|
###############################################################################
# Troubleshooting:
###############################################################################
——————————————————————————-
## Erros conhecidos:
## Sintoma:
Ao tentar iniciar o serviço do apache (/etc/init.d/apache2 start)
aparece a seguinte mensagem de erro:
Forcing reload of web server (apache2)…apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
## Causa:
O daemon do apache não consegui encontrar o nome totalmente qualificado
do apache:
## Solução:
Pode-se colocar a seguinte linha no arquivo
/etc/apache2/apache2
ServerName “dominio.net.br”
|—————————————————————————–|
——————————————————————————-
## Erros conhecidos:
## Sintoma:
## Causa:
Tue Nov 17 12:46:13 2009] [error] [client 10.61.5.117] (13)Permission denied: access to /chpassldapweb/index.xhtml denied
## Solução:
|—————————————————————————–|
###############################################################################
# Referências: #
###############################################################################
Livro Certificação Linux LPI (CLL p. 420)
Site oficial do Apache:
http://www.apache.org/
Install and Configure Apache2 with PHP5 and SSL Support in Debian Etch:
http://www.debianadmin.com/install-and-configure-apache2-with-php5-and-ssl-support-in-debian-etch.html
Como configurar SSL para partes específicas do site:
http://www.gdhpress.com.br/servidores/leia/index.php?p=cap6-15
Usando um certificado reconhecido:
http://www.gdhpress.com.br/servidores/leia/index.php?p=cap6-14
http://www.cahilig.org/create-self-signed-ssl-certifcate-using-openssl-testing-purposes-debianubuntu
http://www.debuntu.org/how-to-create-a-self-signed-certificate
http://www.debian-administration.org/articles/284
###############################################################################
# Mais Coisas: #
###############################################################################
## Veja: http://www.debian-administration.org/articles/31
## Uma outra forma de instalar o Apache com SSL
## Instalar o módulo de SSL do Apache
apt-get install libapache-mod-ssl
|#############################################################################|
*******************************************************************************
Instalar e Configurar o Apache no OpenSuse
Criado por: Alessandro C. M. Kuramoto
Data: 01/12/2008
Modificado em: 06/10/2009-22:06
v.20091006-2206
Palavras-chaves: apache
*******************************************************************************
###############################################################################
# Instalar o Apache no OpenSuse 11.1:
###############################################################################
## Para instalar o Apache 2
zypper install apache2
|#############################################################################|
###############################################################################
# Arquivos de Configuração do Apache no OpenSuse 11.1:
###############################################################################
## Diretório dos arquivos de configuração:
/etc/apache2
## Diretório dos arquivos de configuração dos hosts virtuais:
/etc/apache2/vhosts.d
## Arquivo de configuração principal:
/etc/apache2/httpd.conf
|#############################################################################|
###############################################################################
# Configurando no OpenSuse 11.1:
###############################################################################
===============================================================================
Configuração Geral – Parâmetros Gerais de Configuração – Explicação:
===============================================================================
## e-mail do administrador do servidor:
ServerAdmin alessandrocmk@gmail.com
## Nome do servidor:
ServerName localhost
## Arquivos iniciais:
DirectoryIndex start.html index.html index.html.var
|=============================================================================|
===============================================================================
Configuração Geral – Explicação:
===============================================================================
##
vim /etc/apache2/httpd.conf
_______________________________________________________________________________
OpenSuse 11.1
Arquivo: /etc/apache2/httpd.conf (Permissões: -rw-r–r– 1 root root)
——————————————————————————-
.
..
…
## IP addresses / ports to listen on
Include /etc/apache2/listen.conf
## Arquivos iniciais do site:
DirectoryIndex start.html index.html index.html.var
## Arquivos de configuração dos hosts virtuais:
Include /etc/apache2/vhosts.d/*.conf
…
..
.
|——– /etc/apache2/httpd.conf ——————————————–|
##
vim /etc/apache2/listen.conf
_______________________________________________________________________________
OpenSuse 11.1
Arquivo: /etc/apache2/listen.conf (Permissões: -rw-r–r– 1 root root)
——————————————————————————-
.
..
…
Listen 127.0.0.1:80
…
..
.
|——— /etc/apache2/listen.conf ——————————————|
vim /etc/apache2/vhosts.d/vhost-ccna3.conf
_______________________________________________________________________________
OpenSuse 11.1
Arquivo: /etc/apache2/vhosts.d/vhost-ccna3.conf
(Permissões: -rw-r–r– 1 root root)
——————————————————————————-
.
..
…
<VirtualHost 127.0.0.1:80>
ServerAdmin alessandrocmk@gmail.com
ServerName localhost
DocumentRoot /srv/www/Cisco_Prof/
ErrorLog /var/log/apache2/localhost-ccna3-error_log
CustomLog /var/log/apache2/localhost-ccna3-access_log combined
# don’t loose time with IP address lookups
HostnameLookups Off
<Directory “/srv/www/Cisco_Prof/ccna3-modulo1″>
</Directory>
</VirtualHost>
|——— /etc/apache2/vhosts.d/vhost-ccna3.conf—————————–|