domingo, 26 de julho de 2020

Install MySQL on Debian

# Check here: https://dev.mysql.com/downloads/repo/apt/
wget http://repo.mysql.com/mysql-apt-config_0.8.16-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb
sudo apt update 
sudo apt install mysql-server
sudo systemctl restart mysql
sudo mysql_secure_installation
mysql -u root -p

Install PHP 7.3 on Debian 9 / Debian 8




sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
sudo apt update
sudo apt -y install php7.3

Common Alias

For Debian

vi .bashrc
alias get='sudo apt-get install -y'
alias df='df -h'
alias ls='ls -la'
alias upgrade='sudo apt-get update -y && sudo apt-get autoremove -y'
alias cdwww='cd /var/www/html'
alias myip='curl ifconfig.me'
alias version='lsb_release -a'

For CentOS

vi .bashrc
alias get='sudo yum install -y'
alias df='df -h'
alias ls='ls -la'
alias upgrade='sudo yum update -y'
alias cdwww='cd /var/www/html'
alias myip='curl ifconfig.me'
alias version='hostnamectl'

Debian Upgrade

## First check version

cat /etc/debian_version
uname -a

## From Debian 8 (jessie) to 9 (stretch)

sed -i 's/jessie/stretch/g' /etc/apt/sources.list

apt update -y && apt upgrade -y
apt dist-upgrade

apt autoremove
reboot

## From Debian 9 (stretch) to 10 (buster)
sed -i 's/stretch/buster/g' /etc/apt/sources.list

apt update -y && apt upgrade -y

apt dist-upgrade

apt autoremove
reboot

sábado, 25 de julho de 2020

First server configuration

apt update -y && apt upgrade -y
apt install sudo

### Create user
export USERNAME='user'
export PASSWORD='userpassword'
useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -G sudo ${USERNAME}
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

### SSH Config
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/MaxAuthTries/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "MaxAuthTries 3" >> /etc/ssh/sshd_config
grep "^MaxAuthTries" /etc/ssh/sshd_config

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/PermitRootLogin/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
grep "^PermitRootLogin" /etc/ssh/sshd_config

/etc/init.d/ssh restart

### Install the Basics
apt install curl git net-tools build-essential tmux screen