Vim syntax highlighting for log files

Edit the file ~/.vimrc to enable colored syntax and (optionally) disable line wrap:

syntax on
set nowrap

Create the file ~/.vim/filetype.vim

if exists("did_load_filetypes")
  finish
endif

augroup filetypedetect
  au! BufRead,BufNewFile *.log,*.log.* setf log
augroup END

Create the file ~/.vim/syntax/log.vim

if exists("b:current_syntax")
  finish
endif

syn match fatal ".* FATAL .*"
syn match fatal "^FATAL: .*"
syn match error ".* ERROR .*"
syn match error "^ERROR: .*"
syn match warn  ".* WARN .*"
syn match warn  "^WARN: .*"
syn match debug ".* DEBUG .*"
syn match debug "^DEBUG: .*"

syn match error "^java.*Exception.*"
syn match error "^java.*Error.*"
syn match error "^.*Exception"
syn match error "^\tat .*"

hi fatal ctermfg=Red    ctermbg=Black
hi error ctermfg=Red    ctermbg=Black
hi warn  ctermfg=Yellow ctermbg=Black
hi debug ctermfg=Gray   ctermbg=Black

let b:current_syntax = "log"

Redirect HTTP to HTTPS in Apache

Create a .htaccess file in the web server root with the following content to automatically redirects visitors to HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Use Let's Encrypt in Apache/Ubuntu

It’s a matter of time until hosting providers offer HTTPS on theirs VPS with Let’s Encrypt certificates with a single click, until then…

Install the Let’s Encrypt client:

$ sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

Request the certificate(s). For multiple domains use as many -d domain-name as needed:

$ /opt/letsencrypt/letsencrypt-auto --apache -d example.com -d www.example.com

Let’s Encrypt certificates are valid for 90 days, and you can automate the renewal process using crontab:

$ sudo crontab -e

As the process won’t do anything until the certificates are due for renewal, let’s schedule it once a week (tuesdays at 1 am):

0 1 * * 2 /opt/letsencrypt/letsencrypt-auto renew >> /var/log/letsencrypt.log