Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX

HaNdTriX/install.sh

Last active Feb 19, 2016
Embed
What would you like to do?
Ubuntu nginx pm2 nodejs
#!/bin/bash -e
# Update System
echo 'Update System Packages'
apt-get update
# Install git
echo 'Installing git'
apt-get install git -y
# Install nginx
echo 'Installing git nginx'
apt-get install nginx -y
# Start nginx
echo 'Starting nginx'
service nginx start
# Install node deps
echo 'installing nvm deps'
apt-get install build-essential libssl-dev -y
# # Install MariaDB
# echo 'Installing MariaDB'
# apt-get install software-properties-common
# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
# add-apt-repository 'deb http://mirrors.n-ix.net/mariadb/repo/10.1/ubuntu trusty main'
# apt-get update
# apt-get install mariadb-server -y
# Adding deploy user
echo 'Create user deploy:'
useradd -s /bin/bash --create-home -d /home/deploy -c "deploy user" deploy
echo 'Please choose a deploy sudo password: '
passwd deploy
echo 'Add sudo access to deploy user'
usermod -aG sudo deploy
echo 'Creating dir: /var/www'
mkdir -p /var/www/
chown -R deploy:deploy /var/www
chmod -R 755 /var/www
# Switch to node user
echo 'Switching user from root to node'
su node
echo 'Creating ssh keys'
ssh-keygen -t rsa -C "deploy@streamly.io"
echo 'Installing nvm'
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.profile
echo 'Installing node'
nvm install 0.10
nvm use 0.10
nvm alias default 0.10
echo 'Installing pm2'
npm install -g pm2
# Info for user
echo '# Authorized keys'
echo '##########################################################'
echo 'Don`t forget to copy your pubkey to this server:'
echo 'Just type the following command from yout local machine'
echo ''
echo ' $ ssh-copy-id deployer@streamly.io'
echo ''
echo '# Add server pubkey to github'
echo '##########################################################'
echo 'In order for github to accept this machine you`ll need to'
echo 'copy the following key to you github account'
echo ''
cat ~/.ssh/id_rsa.pub
echo ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.