Setup web server

Initial upgrade

apt update && apt -y upgrade

Time

apt -y install ntp
# Manually follow the instructions at https://developers.google.com/time/guides#linux_ntpd, and then:
service ntp stop && ntpd -gq && service ntp start

Basic non-PPA packages

apt -y install build-essential curl fail2ban htop mailutils ncdu postfix python-setuptools p7zip-full p7zip-rar screen software-properties-common supervisor unzip

SSH

ssh-keygen -t rsa -b 4096 && eval `ssh-agent -s` && ssh-add ~/.ssh/id_rsa && cat ~/.ssh/id_rsa.pub

Git

add-apt-repository -y ppa:git-core/ppa && apt update && apt -y install git

Redis

add-apt-repository -y ppa:chris-lea/redis-server && apt update && apt -y install redis-server

Nginx (nginx-extras)

add-apt-repository -y ppa:nginx/stable && apt update && apt -y install nginx-extras && openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096

Certbot (Let's Encrypt)

cd /opt/ && wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto

PHP

php-7.2

add-apt-repository -y ppa:ondrej/php && apt update && apt -y install php7.2 php7.2-cli php7.2-curl php7.2-fpm php7.2-gd php7.2-intl php7.2-mbstring php7.2-mysql php7.2-pgsql php7.2-xml php7.2-zip

php-7.1

add-apt-repository -y ppa:ondrej/php && apt update && apt -y install php7.1 php7.1-cli php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-mbstring php7.1-mysql php7.1-pgsql php7.1-xml php7.1-zip

php-5.6

add-apt-repository -y ppa:ondrej/php && apt update && apt -y install php5.6 php5.6-cli php5.6-curl php5.6-fpm php5.6-gd php5.6-intl php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-pgsql php5.6-xml php5.6-zip

Composer (requires PHP)

curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WP-CLI (requires PHP)

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && sudo mv wp-cli.phar /usr/local/bin/wp

Node.js

node-10 LTS

{ curl -sL https://deb.nodesource.com/setup_10.x | bash -; } && apt -y install nodejs && npm -g update [email protected]

node-8 LTS

{ curl -sL https://deb.nodesource.com/setup_8.x | bash -; } && apt -y install nodejs && npm -g update [email protected]

node-6

{ curl -sL https://deb.nodesource.com/setup_6.x | bash -; } && apt -y install nodejs && npm -g update [email protected]

CasperJS (requires Node 6.x)

npm -g install casperjs phantomjs

Python

apt install python3-dev python3-venv

For interoperability with PostgreSQL

apt install libpq-dev

MySQL

apt install mysql-server mysql-client

PostgreSQL

postgresql-10 with PostGIS

{ curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; } && { sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; } && add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable && apt update && apt -y install postgresql-10 postgis

postgresql-9.6 with PostGIS

{ curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; } && {sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; } && add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable && apt update && apt -y install postgresql-9.6 postgis

Java 8

add-apt-repository -y ppa:webupd8team/java && apt update && apt -y install oracle-java8-installer

Elasticsearch 2.x (requires Java 8)

{ curl -sSL https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -; } && { echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list; } && apt update && apt -y install elasticsearch && systemctl daemon-reload && systemctl enable elasticsearch && systemctl start elasticsearch
/usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf