功能描述
在Amazon Linux上快速安装开发环境,包括Python 3.11.8, Nodejs, npm, yarn, GO工具。
#!/bin/bash
# @Author : Lan Shiyun
# @Create Time : 2024/3/15
# @FileName : install_development_env.sh
# @Version : 1.0
# @Software : VS Code
# @Update Time : 2024/3/15
# @UpdateBy : Lan Shiyun
# @Description : Shell script to install development environment components on Amazon Linux
# Main function to control the installation process
main() {
echo "Installing Python 3.11.8..."
install_python
python3 -V
echo "Installing Go..."
install_go
go version
echo "Installing Node.js and npm..."
install_nodejs_npm
node --version
echo "Installing Yarn..."
install_yarn
yarn --version
}
# Function to install Python 3.11.8
install_python() {
if ! command -v python3.11 &> /dev/null; then
sudo yum install -y gcc openssl-devel bzip2-devel libffi-devel wget
wget https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tgz
tar -xf Python-3.11.8.tgz
cd Python-3.11.8 || exit
./configure --enable-optimizations
make -j "$(nproc)"
sudo make altinstall
cd ..
sudo rm -rf Python-3.11.8 Python-3.11.8.tgz
else
echo "Python 3.11.8 is already installed."
fi
}
# Function to install Go
install_go() {
if ! command -v go &> /dev/null; then
sudo yum install -y golang
else
echo "Go is already installed."
fi
}
# Function to install Node.js and npm
install_nodejs_npm() {
if ! command -v node &> /dev/null; then
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
else
echo "Node.js is already installed."
fi
if ! command -v npm &> /dev/null; then
sudo npm install -g npm@latest
else
echo "npm is already installed."
fi
}
# Function to install Yarn
install_yarn() {
if ! command -v yarn &> /dev/null; then
npm install -g yarn
else
echo "Yarn is already installed."
fi
}
# Call the main function to start the installation process
main