- Create an executable jar
- Install Java in your EC2 machine
sudo apt install default-jdk
- Copy the jar file ( Either use SCP / compile it on EC2)
- Open EC2 port 8080
- Test using
java -jar demoxxxxx.jar
- Daemonize the app (Deploy Spring boot app)[https://docs.spring.io/spring-boot/docs/current/reference/html/deployment.html#deployment-systemd-service]
File location
sudo nano /etc/systemd/system/term.service
Description=term
After=syslog.target
[Service]
User=ubuntu
ExecStart=/usr/bin/java -jar /home/ubuntu/demo-0.0.1-SNAPSHOT.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
sudo systemctl enable term.service
sudo service term start
- View Logs
journalctl -u term.service
- Install Node on your machine
sudo apt install npm
- Install PM2
sudo npm install -g pm2
- Copy your ExpressJS app
- Install any depedencies
npm install
- Run the app in Pm2
sudo pm2 start bin/www
- Check the logs!
sudo pm2 logs