Created
October 26, 2017 00:07
-
-
Save samuraitruong/8c4fc80e2e9e4a13b1b70b987f3ad6fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
echo "Node Linux Installer by www.github.com/taaem" | |
echo "Need Root for installing NodeJS" | |
sudo su -c 'echo "Got Root!"' | |
echo "Get Latest Version Number..." | |
{ | |
wget --output-document=node-updater.html https://nodejs.org/dist/latest/ | |
ARCH=$(uname -m) | |
if [ $ARCH = x86_64 ] | |
then | |
grep -o '>node-v.*-linux-x64.tar.gz' node-updater.html > node-cache.txt 2>&1 | |
VER=$(grep -o 'node-v.*-linux-x64.tar.gz' node-cache.txt) | |
else | |
grep -o '>node-v.*-linux-x86.tar.gz' node-updater.html > node-cache.txt 2>&1 | |
VER=$(grep -o 'node-v.*-linux-x86.tar.gz' node-cache.txt) | |
fi | |
rm ./node-cache.txt | |
rm ./node-updater.html | |
} &> /dev/null | |
echo "Done" | |
DIR=$( cd "$( dirname $0 )" && pwd ) | |
echo "Downloading latest stable Version $VER..." | |
{ | |
wget https://nodejs.org/dist/latest/$VER -O $DIR/$VER | |
} &> /dev/null | |
echo "Done" | |
echo "Installing..." | |
cd /usr/local && sudo tar --strip-components 1 -xzf $DIR/$VER | |
rm $DIR/$VER | |
echo "Finished installing!" | |
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000 | |
export PATH="$PATH:/usr/local/bin" | |
npm install -g pm2 | |
mkdir /var/www | |
npm init -f -y | |
npm install express-generator -g | |
express /var/www | |
cd /var/www | |
npm install | |
pm2 start ./bin/www | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment