script install droplet digital ocean

// https://www.bitvise.com/ssh-client-download for windows
// 
sudo apt install htop
sudo apt install net-tools
sudo apt  install nginx
// https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
// optiona 3 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04
source ~/.bashrc
nvm list-remote
nvm install v18.19.1
node -v


// mysql https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-22-04
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql.service
sudo mysql_secure_installation
mysql -u root -p
// enter luon khong can nhap pass
CREATE USER 'xxx'@'%' IDENTIFIED BY 'xxx';
GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'%';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'xxx'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
create database countryguess;


// open port cho ben ngoai connect vao duoc
// https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql
cd /etc/mysql/mysql.conf.d
ll
vi mysqld.cnf
// add line
bind-address        = 0.0.0.0
sudo systemctl restart mysql.service
 
// mo port va test connect
// https://www.digitalocean.com/community/tutorials/opening-a-port-on-linux
sudo ufw allow 3306
sudo ufw allow 443
sudo ufw allow 80
// check port
ss -lntu


// add ssh-key
ssh-keygen -t rsa -b 4096
// enter 2 phat
cat ~/.ssh/id_rsa.pub
// nho thay cai {ip} thanh link server
cat ~/.ssh/id_rsa.pub | ssh root@{ip} "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
// nhap password server



Last updated