a2enmod módulo; similarmente, podrá desactivar un módulo ejecutando a2dismod módulo. En realidad, estos programas sólo crean (o eliminan) enlaces simbólicos en /etc/apache2/mods-enabled/ que apuntan a los archivos en sí (almacenados en /etc/apache2/mods-available/).
/etc/apache2/ports.conf) y servirá páginas del directorio /var/www/html/ (según se encuentra configurado en /etc/apache2/sites-enabled/000-default.conf).
mod_ssl) required for secure HTTP (HTTPS) out of the box. It just needs to be enabled with a2enmod ssl, then the required directives have to be added to the configuration files. A configuration example is provided in /etc/apache2/sites-available/default-ssl.conf.
SSLCertificateFile /etc/letsencrypt/live/DOMAIN/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN/chain.pem SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt
mod_gnutls, which is shipped with the libapache2-mod-gnutls package and enabled with the a2enmod gnutls.
/etc/apache2/sites-enabled/000-default.conf; utilizará este servidor virtual si no se encuentra ningún servidor que coincida con el pedido enviado por el cliente.
/etc/apache2/sites-available/. La configuración de un sitio web para el dominio falcot.org es tan simple como crear el siguiente archivo y luego habilitar el servidor virtual con a2ensite www.falcot.org.
Ejemplo 11.13. El archivo /etc/apache2/sites-available/www.falcot.org.conf
<VirtualHost *:80> ServerName www.falcot.org ServerAlias falcot.org DocumentRoot /srv/www/www.falcot.org </VirtualHost>
CustomLog en las definiciones de servidores virtuales). Por lo tanto, tiene sentido personalizar el formato de este archivo de registro para incluir el nombre del servidor virtual. Puede hacerlo creando un archivo /etc/apache2/conf-available/customlog.conf que define un nuevo formato para todos los archivos de registro (con la directiva LogFormat) y habilitándolo con la orden a2enconf customlog. También debe eliminar (o comentar) la línea CustomLog del archivo /etc/apache2/sites-available/000-default.conf.
Ejemplo 11.14. The /etc/apache2/conf-available/customlog.conf file
# Nuevo formato de registro que incluye el nombre del servidor (virtual)
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost
# Ahora utilicemos este formato de forma predeterminada
CustomLog /var/log/apache2/access.log vhostDirectory que permiten diferentes comportamientos del servidor dependiendo de la ubicación del archivo que está proveyendo. Tales bloques usualmente incluyen directivas Options y AllowOverride.
Ejemplo 11.15. Bloque Directory
<Directory /srv/www> Options Includes FollowSymlinks AllowOverride All DirectoryIndex index.php index.html index.htm </Directory>
DirectoryIndex contiene una lista de archivos a intentar cuando el pedido del cliente es un directorio. El primer archivo de la lista que exista será utilizado y enviado como respuesta.
Options debe seguirse de una lista de opciones a activar. El valor None desactiva todas las opciones; correspondientemente, All las activa todas excepto MultiViews. Las opciones disponibles incluyen:
ExecCGI indicates that CGI scripts can be executed.
FollowSymlinks tells the server that symbolic links can be followed, and that the response should contain the contents of the target of such links.
SymlinksIfOwnerMatch also tells the server to follow symbolic links, but only when the link and the its target have the same owner.
Includes enables Server Side Includes (SSI for short). These are directives embedded in HTML pages and executed on the fly for each request.
IncludesNOEXEC allows Server Side Includes (SSI) but disables the exec command and limits the include directive to text/markup files.
Indexes tells the server to list the contents of a directory if the HTTP request sent by the client points at a directory without an index file (i.e., when no files mentioned by the DirectoryIndex directive exists in this directory).
MultiViews enables content negotiation; this can be used by the server to return a web page matching the preferred language as configured in the browser.
AllowOverride enumera todas las opciones que pueden ser activadas o desactivadas en un archivo .htaccess. Un uso común de esta opción es restringir ExecCGI para que los administradores puedan elegir los usuarios que podrán ejecutar programas bajo la identidad del servidor web (el usuario www-data).
Ejemplo 11.16. Archivo .htaccess para autenticación obligatoria
Require valid-user AuthName "Private directory" AuthType Basic AuthUserFile /etc/apache2/authfiles/htpasswd-private
/etc/apache2/authfiles/htpasswd-private file contains a list of users and passwords; it is commonly manipulated with the htpasswd command. For example, the following command is used to add a user or change their password:
#htpasswd /etc/apache2/authfiles/htpasswd-private usuarioNew password: Re-type new password: Adding password for user usuario
Require directive controls access restrictions for a directory (and its subdirectories, recursively).
Require combinadas con un bloque RequireAll.
/etc/awstats/awstats.conf. Los administradores de Falcot lo mantuvieron sin cambios más que los siguientes parámetros:
LogFile="/var/log/apache2/access.log" LogFormat = "%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" SiteDomain="www.falcot.com" HostAliases="falcot.com REGEX[^.*\.falcot\.com$]" DNSLookup=1 LoadPlugin="tooltips"
LogFile y LogFormat describen la ubicación y el formato del archivo de registros y la información que contiene; SiteDomain y HostAliases enumeran los varios nombres con los que se conocerá el sitio web principal.
DNSLookup como 1; para sitios más pequeños, como el de Falcot ya descripto, esta configuración permite conseguir reportes más legibles que incluyen nombres completos de equipos en lugar de sólo direcciones IP.
/etc/awstats/awstats.www.falcot.org.conf.
Ejemplo 11.18. Archivo de configuración de AWStats para un servidor virtual
Include "/etc/awstats/awstats.conf" SiteDomain="www.falcot.org" HostAliases="falcot.org"
/usr/share/awstats/icon/. Para que éstos estén disponibles en el sitio web, necesita adaptar la configuración de Apache para incluir la siguiente directiva:
Alias /awstats-icon/ /usr/share/awstats/icon/