Last active
December 2, 2020 01:32
-
-
Save paulkre/06299fec86a06db54b7ed517ad4dc5a4 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
set -x | |
# Install Node.js for Debian | |
curl -sL https://deb.nodesource.com/setup_12.x | bash - | |
apt-get install -y nodejs | |
sudo apt-get install gcc g++ make | |
# Install yarn | |
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update && sudo apt-get install yarn | |
# Install pm2 | |
sudo yarn global add pm2 | |
# Register pm2 as systemd unit | |
pm2 startup | |
# Add pm2 commands to PATH variable | |
sudo env PATH=$PATH:/usr/bin /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 startup systemd -u bitnami --hp /home/bitnami | |
# Change Nginx configuration | |
echo 'location / { | |
proxy_pass http://localhost:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Port $server_port; | |
}' > /opt/bitnami/nginx/conf/bitnami/app.conf | |
sudo /opt/bitnami/ctlscript.sh restart nginx | |
# Allow SSH connections to unknown hosts | |
echo "Host * | |
StrictHostKeyChecking no" > .ssh/config | |
sudo chmod 600 .ssh/config | |
ssh-keyscan -H github.com > .ssh/known_hosts | |
# Generate SSH key | |
cat /dev/zero | ssh-keygen -q -N "" | |
echo "Follo this tutorial to enable HTTPS: https://docs.bitnami.com/aws/how-to/generate-install-lets-encrypt-ssl/#alternative-approach" | |
# Reboot the server | |
sudo reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment