yum install git openssl libssl-dev curl
下載nvm
git clone https://github.com/creationix/nvm.git /opt/nvm
建立安裝目錄
mkdir /usr/local/nvm
/usr/local/node
chown root.web /usr/local/nvm
chmod 775 /usr/local/nvm
建立 /etc/profile.d/nvm.sh 給所有使用者 source 用
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh
一鍵安裝 shell script
#!/bin/bash
group0='web'
yum install -y git openssl libssl-dev curl
groupadd $group0
git clone https://github.com/creationix/nvm.git /opt/nvm
modify() {
chown -R root.$group0 /usr/local/$1
chmod -R 775 /usr/local/$1
}
for i in nvm
do
if [ -d "/usr/local/$i" ];then
modify $i
else
mkdir /usr/local/$i
modify $i
fi
done
echo 'export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh' > /etc/profile.d/nvm.sh
read -p "Input a username : " user
if [ "$user" != "" ];then
usermod -G $group0 $user
else
echo "Please add user to $group0 group! "
fi
reference:Ubuntu下如何給所有用戶安裝nodejs的nvm
0 意見:
張貼留言