Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Last active October 14, 2017 20:39
Show Gist options
  • Save vladimir-e/8d1f37dd4fc3bebaf3870a5a356d8748 to your computer and use it in GitHub Desktop.
Save vladimir-e/8d1f37dd4fc3bebaf3870a5a356d8748 to your computer and use it in GitHub Desktop.
Ubuntu 16.04 web server / Digitalocean
apt-get -y update
apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties vim mc
# Check locale
locale
# Edit locale file if some ENV variables are missing
vim /etc/default/locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
# Add deployer user
groupadd deployer
adduser deployer --ingroup deployer
sudo adduser deployer sudo
su deployer
cd
# configure SSH key login for user
mkdir .ssh
cat ~/.ssh/id_rsa.pub # copy public key from the host
vim ~/.ssh/authorized_keys # insert on server
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
# https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04
sudo apt-get install nginx
# Disable root login https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04
sudo vim /etc/ssh/sshd_config
PermitRootLogin no
sudo service ssh restart
# firewall https://www.digitalocean.com/community/tutorials/additional-recommended-steps-for-new-ubuntu-14-04-servers
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 25/tcp
sudo ufw show added
sudo ufw enable
sudo dpkg-reconfigure tzdata
# ZSH https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH
sudo apt-get -y install zsh
chsh -s $(which zsh)
# relogin
echo $SHELL # should be /usr/bin/zsh
# https://github.com/robbyrussell/oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@vladimir-e
Copy link
Author

vladimir-e commented Oct 5, 2017

Swap

How To Add Swap Space on Ubuntu 16.04

sudo swapon --show
free -h
df -h
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
# Make it permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
cat /proc/sys/vm/swappiness
cat /proc/sys/vm/vfs_cache_pressure
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50
sudo vim /etc/sysctl.conf
# at the bottom
vm.swappiness=10
vm.vfs_cache_pressure=50

@vladimir-e
Copy link
Author

vladimir-e commented Oct 5, 2017

Erlang for elixir apps

wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install erlang
erl # test
sudo apt-get install elixir

@vladimir-e
Copy link
Author

vladimir-e commented Oct 14, 2017

PostgreSQL

sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6

Now that we’ve installed PostgreSQL, let’s create a database.

sudo -i -u postgres
psql

This opens a psql console.

postgres=# CREATE DATABASE app_prod;
postgres=# CREATE USER apps WITH PASSWORD 'mypassword';
postgres=# GRANT ALL PRIVILEGES ON DATABASE app_prod TO apps;

@vladimir-e
Copy link
Author

Nodejs

curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment