Skip to content

Instantly share code, notes, and snippets.

@ernado
Last active October 27, 2017 15:27
Show Gist options
  • Select an option

  • Save ernado/db1d69a3bd5c02fac5d76a20a7cb4a8f to your computer and use it in GitHub Desktop.

Select an option

Save ernado/db1d69a3bd5c02fac5d76a20a7cb4a8f to your computer and use it in GitHub Desktop.
Ubuntu 16.04 initial installation handbook

Server install handbook

First of all

sudo apt install htop nano bash-completion man software-properties-common

Adding user

adduser ernado
usermod -aG sudo ernado

Updating locale

sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

Installing nginx

sudo apt-key adv --fetch-keys http://nginx.org/keys/nginx_signing.key
sudo add-apt-repository -u 'deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx'
sudo apt install nginx

LetsEncrypt

# export CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY
lego --dns cloudflare --domains x.dd.com --email user@domain.com run

# CLOUDFLARE_EMAIL=email
# CLOUDFLARE_API_KEY=key
# into /etc/lego-dd.env
# and
sudo chmod o-r /etc/lego-dd.env
# to prevent read

Systemd

[Unit]
Description=Renew LetsEncrypt certs

[Service]
Type=oneshot
User=dd
EnvironmentFile=/etc/lego-dd.env
ExecStart=/usr/bin/lego --dns cloudflare -d x.dd.cc --email user@domain.com renew
WorkingDirectory=/home/dd

[Install]
WantedBy=multi-user.target

Timer

[Unit]
Description=Run cert renew every .05d

[Timer]
OnUnitActiveSec=12h 32min

[Install]
WantedBy=timers.target

nginx conf

server {
  server_name x.cydev.ru;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate     /home/cydev/.lego/certificates/x.cydev.ru.crt;
  ssl_certificate_key /home/cydev/.lego/certificates/x.cydev.ru.key;
  location /webrtc {
    alias /home/cydev/x/webrtc;
  }
}

Yandex apt mirror

sed -e '/^#/! s/us.archive.ubuntu.com/mirror.yandex.ru/g' /etc/apt/sources.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment