# This is an example virtual host configuration in /etc/apache2/sites-available/ # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # # Option 1: Read entire log file # # Create authentication database using command-line: # mkdir -p /usr/local/etc/apache2 # htpasswd -c /usr/local/etc/apache2/htpasswd_errorlog tj # Add additional users with: # htpasswd /usr/local/etc/apache2/htpasswd_errorlog username # # Enable access to the log directory with: # sudo chmod o+x /var/log/apache2 # sudo chmod o+r /var/log/apache2/error.log # Alias /apacheErrors.log /var/log/apache2/error.log AuthType Basic AuthName "Server Logs" AuthBasicProvider file AuthUserFile "/usr/local/etc/apache2/htpasswd_errorlog" Require valid-user # # Option 2: Read last 100 lines of log file # # First create an executable shell script: # mkdir -p /usr/local/etc/apache2/cgi-bin # # Add this content to the file /usr/local/etc/apache2/cgi-bin/error.log # #!/bin/sh # echo "Content-type: text/plain\n\n" # tail -n 100 /var/log/apache2/error.log # # Make the script executable # chmod +x /usr/local/etc/apache2/cgi-bin/error.log # # Enable the CGI module: # sudo a2enmod cgi # # Add to the virtual host as in Option 1 and create authentication database # as detailed in Option 1. # # Reload the server configuration # sudo apache2ctl graceful # ScriptAlias "/cgi-bin/" "/usr/local/etc/apache2/cgi-bin/" AuthType Basic AuthName "Server Logs" AuthBasicProvider file AuthUserFile "/usr/local/etc/apache2/htpasswd_errorlog" Require valid-user # vim: syntax=apache ts=4 sw=4 sts=4 sr noet