musicgacha

Home Night at Museum Final Progress Updates Sponsor Objectives Coding Plan Deployment(Hosting Plan)

AWS Deployment

Update, Upgrade, and install Maven

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install maven
$ sudo apt-get install git

Clone project and test Java Web Application

$ sudo git clone https://github.com/zenxha/musicgacha.git
$ cd musicgacha
$ sudo mvn package
$ sudo java -jar /home/ubuntu/musicgacha/target/coders-0.0.1-SNAPSHOT.jar

Setup Security Groups for HTTP and HTTPS

Inbound Rules

Outbound Rules

Setup NGINX

$ sudo apt-get install nginx
$ sudo nano /etc/nginx/sites-available/musicgacha
server {
    listen 80;
    server_name musicgacha.cf;

    location / {
        proxy_pass http://localhost:8080;
    }
}

Test nginx file configuration

$ sudo ln -s /etc/nginx/sites-available/musicgacha /etc/nginx/sites-enabled
$ sudo nginx -t

If no errors occur when “sudo nginx -t” is checked, continue

$ sudo systemctl restart nginx

Setup Certbot(HTTPS)

sudo apt-get install snapd
sudo certbot --nginx

If the certificate expires after the 3 month certificate period, do

sudo certbot renew

Create Service File

“sudo nano” into new service file in /etc/systemd/system/musicgacha.service

[Unit]
Description=Java
After=network.target

[Service]
User=ubuntu
Restart=always
ExecStart=java -jar /home/ubuntu/musicgacha/target/coders-0.0.1-SNAPSHOT.jar

[Install]
WantedBy=multi-user.target 

Run and enable service file for the project

$ sudo systemctl start musicgacha
$ sudo systemctl status musicgacha

If running the service file is successful, make the service file persistent on the machine(always running whenever the machine starts up and is on)

$ sudo systemctl enable musicgacha