Created
August 8, 2020 11:20
-
-
Save realmayus/42b4de34a21f8b27bf22f3e23038c984 to your computer and use it in GitHub Desktop.
Set up web environment & install chime-web and chime-backend
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
GREEN='\033[0;32m' | |
NC='\033[0m' | |
echo -e "${GREEN}> Adding Ubuntu Universe to repositories & Updating package lists${NC}" | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository universe | |
sudo apt-get update | |
echo -e "${GREEN}> Installing nodejs & npm${NC}" | |
sudo apt install -y nodejs npm | |
echo -e "${GREEN}> Installing nginx & certbot${NC}" | |
sudo apt install -y nginx certbot python3-certbot-nginx | |
echo -e "${GREEN}> Cloning backend${NC}" | |
cd | |
git clone https://github.com/realmayus/chime-backend.git | |
echo -e "${GREEN}> Creating nginx profile for backend${NC}" | |
sudo rm /etc/nginx/sites-enabled/chime-backend | |
sudo tee /etc/nginx/sites-enabled/chime-backend << EOF | |
server { | |
listen 80; | |
server_name api.realmayus.xyz; | |
location / { | |
proxy_pass http://localhost:5000; | |
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; | |
} | |
} | |
EOF | |
echo -e "${GREEN}> Cloning frontend${NC}" | |
cd | |
git clone https://github.com/realmayus/chime-web.git | |
echo -e "${GREEN}> Creating nginx profile for frontend${NC}" | |
sudo rm /etc/nginx/sites-enabled/chime-web | |
sudo tee /etc/nginx/sites-enabled/chime-web << EOF | |
server { | |
listen 80; | |
server_name chime.realmayus.xyz; | |
location / { | |
root /var/www/html/chime-web; | |
try_files \$uri /index.html; | |
} | |
} | |
EOF | |
echo -e "${GREEN}> Enabling SSL for backend using certbot${NC}" | |
sudo certbot --nginx -d api.realmayus.xyz | |
echo -e "${GREEN}> Enabling SSL for frontend using certbot${NC}" | |
sudo certbot --nginx -d chime.realmayus.xyz | |
echo -e "${GREEN}> Creating systemd service for backend${NC}" | |
sudo rm /etc/systemd/system/chime-backend.service | |
sudo tee /etc/systemd/system/chime-backend.service << EOF | |
[Unit] | |
Description=chime-backend | |
After=multi-user.target | |
[Service] | |
WorkingDirectory=/home/realmayus/chime-backend | |
ExecStart=node /home/realmayus/chime-backend/app.js | |
Type=idle | |
Restart=always | |
RestartSec=1 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
echo -e "${GREEN}> Starting systemd service${NC}" | |
sudo service chime-backend restart | |
echo -e "${GREEN}> Restarting nginx" | |
sudo service nginx restart | |
echo -e "${GREEN}########################${NC}" | |
echo -e "${GREEN}# Done! #${NC}" | |
echo -e "${GREEN}########################${NC}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment