Created
May 24, 2018 17:22
-
-
Save JamesTheHacker/7041ad978ba9c5018ebda1f1ec9988e8 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
server 🦄 npm run api:provision-dev | |
> [email protected] api:provision-dev /Users/spongebob/Projects/fb-app/server | |
> ssh -tt dev 'bash -s' < scripts/provision.sh | |
[email protected]'s password: | |
#!/bin/bash | |
# Download NodeJS installation script | |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
# Install required packages | |
sudo apt-get update | |
sudo add-apt-repository ppa:certbot/certbot | |
sudo apt-get update | |
sudo apt-get install -y \ | |
nodejs \ | |
build-essential \ | |
nginx \ | |
software-properties-common \ | |
python-certbot-nginx | |
# Create new unprivilated user and add them to the www-data group | |
sudo adduser $UNPRIVILAGED_USER | |
sudo usermod -a -G www-data $UNPRIVILAGED_USER | |
# Generate SSL certificate and automatically configure nginx. This | |
# will enable SSL on the server. We're going to run in standalone | |
# mode | |
#certbot \ | |
# --standalone \ | |
# --agree-tos \ | |
# --non-interactive \ | |
# --email $CERTBOT_EMAIL \ | |
# --nginx | |
# Copy nginx default config | |
sudo mv /tmp/server/default /etc/nginx/sites-available/default | |
sudo systemctl restart nginx | |
# Move application files to home dir | |
sudo cp /tmp/server/* /home/web | |
npm install --prefix /home/web | |
# Install pm2 | |
sudo npm install -g pm2 | |
# Configure pm2 | |
sudo pm2 start /home/web/server.js --watch | |
sudo pm2 startup systemd | |
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u web --hp /home/web | |
# Setup firewall | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing | |
sudo ufw allow ssh | |
sudo ufw allow http | |
sudo ufw allow https | |
# Start UFW | |
sudo ufw enable | |
# Clean up | |
sudo rm /home/web/install.sh | |
sudo rm -rf /tmp/server | |
echo "Deployment Complete!"dev@ubuntu:~$ #!/bin/bash | |
dev@ubuntu:~$ | |
dev@ubuntu:~$ | |
dev@ubuntu:~$ # Download NodeJS installation script | |
dev@ubuntu:~$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
[sudo] password for dev: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment