Created
February 11, 2017 22:24
-
-
Save yuzhakovvv/19b5c419ec30663b818f64a01de5f78f to your computer and use it in GitHub Desktop.
BASH Scripts to Setup a Server for Front/Back
This file contains hidden or 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
#!/usr/bin/env bash | |
apt-get -y update; | |
apt-get -y upgrade; | |
apt-get -y install htop; | |
#swap file | |
cd /var; | |
touch swap.img; | |
chmod 600 swap.img; | |
dd if=/dev/zero of=/var/swap.img bs=1024k count=2000; | |
mkswap /var/swap.img; | |
swapon /var/swap.img; | |
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab; | |
#node | |
curl -sL https://deb.nodesource.com/setup_6.x | bash -; | |
apt-get install -y nodejs; | |
#git | |
apt-get -y install git-core; | |
#bower | |
npm install -g bower; | |
#gulp | |
npm install -g gulp-install; | |
npm install --save gulp-install; | |
npm install gulp -g; | |
#nginx | |
apt-get install -y nginx; | |
echo 'server { | |
listen 80 default_server; | |
server_name _; | |
root /home/node/apps/cap-commissioner-fe; | |
index index.html; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
} | |
server { | |
listen 8080; | |
server_name _; | |
location / { | |
proxy_pass http://127.0.0.1:1234; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_connect_timeout 120; | |
proxy_send_timeout 120; | |
proxy_read_timeout 180; | |
} | |
} | |
' > /etc/nginx/sites-available/default | |
service nginx restart; | |
#forever | |
npm i forever -g | |
#mongo | |
apt-get -y install mongodb-server -y; | |
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10; | |
echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list; | |
apt-get update; | |
apt-get install mongodb-org -y; | |
service mongodb start; | |
#create user | |
adduser node --disabled-password; | |
mkdir /home/node/.ssh; | |
ssh-keyscan git.codemotion.eu >> /home/node/.ssh/known_hosts | |
chown -R node:node /home/node/.ssh; | |
#create folder | |
runuser -l node -c 'mkdir ~/apps;'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment