update and upgrade packages
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y
install some packages
apt-get install htop mc screen tmux mtr git vim build-essential zsh net-tools fail2ban mlocate -y
fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
nginx
apt-get install nginx -y
firewall
ufw allow http
ufw allow https
ufw allow ssh
ufw enable
ufw status
rbenv
apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev -y
cd /opt
git clone https://github.com/rbenv/rbenv.git
git clone https://github.com/sstephenson/ruby-build.git rbenv/plugins/ruby-build
echo 'export RBENV_ROOT=/opt/rbenv' >> /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
rbenv rehash
echo "gem: --no-ri --no-rdoc" >/root/.gemrc
CONFIGURE_OPTS="--disable-install-doc" rbenv install 3.2.1
rbenv global 3.2.1
gem install bundler
Node.js and Yarn
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update; apt install nodejs yarn -y
Install MySQL
apt-get install mysql-server
mysql_secure_installation
Install PostgreSQL
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list'
apt-get update
apt install postgresql postgresql-contrib -y
Install Certbot
apt install snapd -y
snap install core;snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
snap set certbot trust-plugin-with-root=ok
Add www user
adduser --home /www www
usermod -aG sudo www
gpasswd -d www sudo # remove from goup
zsh
chsh -s /bin/zsh www
(sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)")
Docker
apt-get install apt-transport-https ca-certificates software-properties-common -y
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
usermod -aG docker dock
Docker Compose
curl -L "https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Add Swap
cd /
touch swapfile.img
chmod 600 swapfile.img
dd if=/dev/zero of=/swapfile.img bs=1024k count=1000
mkswap /swapfile.img
swapon /swapfile.img
echo "/swapfile.img none swap sw 0 0" >> /etc/fstab