node.js 설치 script
Code
#!/usr/bin/env bash
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.nvm/nvm.sh
nvm --version
nvm install node --lts
node --version
source ~/.bashrc
다운로드 후 실행
curl -o- https://raw.githubusercontent.com/cloudcoke/script/main/node_js_install/node.sh | bash
source ~/.bashrc
Front Server
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3005
mysql 세팅 script
Code
#!/usr/bin/env bash
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt install mysql-server -y
sudo systemctl start mysql
echo "Setting MySQL Root Account"
while :; do
echo -n "Enter the password of the MySQL root account to use : "
read -s PW
echo
echo -n "Re-enter your MySQL root account password : "
read -s RPW
echo
if [ $PW == $RPW ]; then
break
else
echo "Passwords do not match."
fi
done
sudo mysql -u root -e "alter user 'root'@'localhost' identified with mysql_native_password by '$PW'"
sleep 1
echo
echo "Complete root Password"
echo
read -p "Do you want to create a MySQL user account : [y/n] " ANSWER
case $ANSWER in
[Yy]*)
read -p "Enter the create user name : " USERNAME
while :; do
echo -n "Enter the password of the $USERNAME account to use : "
read -s USERPW
echo
echo -n "Re-enter your password : "
read -s USERRPW
echo
if [ $USERPW == $USERRPW ]; then
break
else
echo "Passwords do not match."
fi
done
read -p "Do you want to allow external access : [y/n] " ALLOWACCESS
case $ALLOWACCESS in
[Yy]*)
SETIP='%'
sudo sed -i '0,/bind-address/{s/bind-address.*/bind-address = 0.0.0.0/}' /etc/mysql/mysql.conf.d/mysqld.cnf
;;
[Nn]*)
SETIP=localhost
;;
esac
sudo mysql -u root -p$PW <<QUERY
create user '$USERNAME'@'$SETIP' identified with mysql_native_password by '$USERPW';
grant all privileges on *.* to '$USERNAME'@'$SETIP' with grant option;
QUERY
;;
[Nn]*) ;;
esac
read -p "Do you want to create database : [y/n] " DBANSWER
case $DBANSWER in
[Yy]*)
read -p "Enter the create database name : " DBNAME
sudo mysql -u root -p$PW <<SETTING
create database $DBNAME
SETTING
sleep 1
echo
echo "Complete create database"
;;
[Nn]*) ;;
esac
sudo systemctl restart mysql
echo "Setting is complete"
다운로드 후 실행
curl -O https://raw.githubusercontent.com/cloudcoke/script/main/mysql_ec2_set/mysql.sh && bash mysql.sh
Back Server
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000